I am trying to figure out how to handle this, the results are not coming back, how would I do this?
while ($ row = mysql_fetch_array ($ Result))
So if there are results: print them
else: show link
http://ca3.php.net/manual/en/function.mysql-num-rows.php
if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { ... } } else { // show link }
You can use mysql_num_rows()to find out how many results are found. Using this with a simple one if-statement, and you can determine what action to take.
mysql_num_rows()
if-statement
if (mysql_num_rows($result) > 0) { // do while loop } else { // show link }
mysql_num_rows(), , , . mysql_unbuffered_query(), .
mysql_unbuffered_query()
:
$found_row = false; while ($row = mysql_fetch_array($result)) { $found_row = true; . . . } if ($found_row == false) { // show link }
$found_row true, . , SQL-.
$found_row
mysql_num_rows :
mysql_num_rows
if($result) { // return db results } else { // no result }
if (!($row = mysql_fetch_array($descResult))) { echo "<tr><td>Add Link</td></tr>"; }
mysql_num_rows() ()
if ( false===($row=mysql_fetch_array($result, MYSQL_ASSOC)) ) { echo 'no rows in result set'; } else { do { echo $row['X']; } while ( false===($row=mysql_fetch_array($result, MYSQL_ASSOC)) ); }
fetch ( if-statement while-clause).