Re: mysql if empty
| From: | Jim Lucas | Date: | Wed, 11 Apr 2007 00:53:42 +0000 |
| Subject: | Re: mysql if empty | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-252521@lists.php.net to get a copy of this message | ||
Richard Lynch wrote:
I am amazed by the sheer number of just plain WRONG answers to this one... Were they all from April 1 or something?... so, are you saying that my answer was wrong, or just making a statement.If my answer was wrong, it was because it was too simple, which is what I was trying to get at, so as not to confuse the OP. Anyways, here is the expanded version hopefully to your liking. <?php // do that db connection thing... // select you database $sql = "SELECT Client FROM booked WHERE Name = 'larry' "; if ( ( $result = mysql_query($sql) ) === false ) { # Your request failed. Make up your own custom way of displaying the error. } else { if ( mysql_num_rows($results) > 0 ) { while ( $row = mysql_fetch_assoc($result) ) { if ( isset($row['client']) && !empty($row['client']) ) { echo $row['client'] . '<br />'; } } } else { echo 'No results found!'; } } ?> Does this satisfy you?