Results 1 to 4 of 4

Thread: if problem?

  1. #1
    Join Date
    May 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default if problem?

    hey guys im trying to output something if a querry is empty?

    PHP Code:
    <?php
    $QQQ4 
    mysql_query("  SELECT *
    FROM `tests` 
    LIMIT 0 , 30 "
    );

    if(
    mysql_num_rows($QQQ4) == 0)
    {
    $QQQ4 'to come';
    }
    i have this done but it does not work?whats wrong with it?

    if it empty it gives me

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in url on line 37

  2. #2
    Join Date
    May 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ok i found this in the manuel
    Code:
    $q = "SELECT * FROM tests";
    $res = mysql_query($q);
    $row = mysql_fetch_assoc($res);
    echo (empty($row['d'])? "empty": "not empty");
    works great but i want it to echo the content if there is not not empty

  3. #3
    Join Date
    Jul 2007
    Location
    Irmo, SC
    Posts
    96
    Thanks
    10
    Thanked 7 Times in 7 Posts

    Default

    try this

    Code:
    <?php
    $QQQ4 = mysql_query("  SELECT *
    FROM `tests` 
    LIMIT 0 , 30 ");
    
    if(!mysql_num_rows($QQQ4))
    {
    $QQQ4 = 'to come';
    }

  4. #4
    Join Date
    May 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i got it going with this.the only think is that it links the empty to...

    [code]
    $q = "SELECT * FROM tests";
    $res = mysql_query($q);
    $row = mysql_fetch_assoc($res);


    <a href="events.php?id=<?php echo $row['id'] ?>"target="_blank"><? echo (empty($row['evenement'])? "A venir": $row['evenement']);
    ?></a>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •