Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    147
    Thanks
    31
    Thanked 2 Times in 2 Posts

    select returns nothing?

    Hi

    How do I check if my SELECT statment returns nothing. then it must echo "returns nothing";

    Because right now if the customer_ID doesn't exist it wont echo anything.

    Thanks




    PHP Code:
    $sql_search_users "SELECT * FROM customers_for_store WHERE customer_ID = $_X ";
        

        
    $result mysql_query($sql_search_users$con_connect) or die('Error: '.mysql_error());

        
      
        while (
    $row mysql_fetch_array($result)) {

                echo 
    "<br /><br />".$row['customer_ID']."    ".$row['first_name']." ".$row['last_name']."  ".$row['credits_left']."   ".$row['date_joined'].".<br /><br />";

        } 

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    http://us.php.net/manual/en/function.mysql-num-rows.php

    PHP Code:
    if(mysql_num_rows($result) < 1){ echo 'No rows returned';}else{do other stuff;} 

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    147
    Thanks
    31
    Thanked 2 Times in 2 Posts
    Thank you....


  •  

    Posting Permissions

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