More specific SELECT result

Discussion in 'PHP' started by micromark, Oct 25, 2007.

  1. #1
    Hi all.

    When im getting the result from my table I have told the script to pick out 2 columns : 1 being the username and the other a quote by that user.

    Now...that works fine but I only want it to display the result if someone has left a quote.

    Is there a way I can get the code to determin - display quote if text is there, if no text , dont display.


    Code so far

    
    $query="SELECT username,quote FROM members";
    $result=mysql_query($query);
    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    echo "Name :{$row['username']} <br>".
         "Quote : {$row['quote']} <br>";
    }
    PHP:
     
    micromark, Oct 25, 2007 IP
  2. gota

    gota Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Something like...

    $query="SELECT username,quote FROM members WHERE quote <> ''";
    PHP:
    or

    $query="SELECT username,quote FROM members WHERE quote != ''";
    PHP:
    They mean the same thing (<>, !=, not equal)
     
    gota, Oct 25, 2007 IP