How To Find Number Of Rows Returned: MySQL
Computing : Learning PHP Using mySQL there are many helper functions that tell you for instance how many rows are returned by a query. Thus if you issue this query: $whatever = mysql_query("SELECT * FROM members"); then to see how many rows are returned there we can do this: $rows_returned = mysql_num_rows($whatever); and we now know how many rows. This is useful if we want to display different info if no rows are returned and not for instance construct a table to hold returned data. Since if there are no rows returned then the variable will evaluate to 0 and therefore false, you could do this: if (!$rows_returned = mysql_num_rows($whatever)) { echo "Sorry, no results"; } else { // process data returned }
Questions about PHP and mySQL:
|
|