Jump to content

empty results in mysql_fetch_array


jmeulemans

Recommended Posts

I am displaying a table from query results. One column (web) contains URLs which I am converting to links. The problem I am having is that it's also adding the links to empty fields.  How can I this action from happening on empty rows?

 

$sql = "SELECT name,certificate,employer,city,state,web FROM table_1 ORDER by name";

$dbq = mysql_query($sql,$dbc);

 

echo "<TABLE>";

while ($row = mysql_fetch_array($dbq)) {

echo "<TR>";

echo "<TD>".$row['name']."</TD>";

echo "<TD>".$row['certificate']."</TD>";

echo "<TD>".$row['employer']."</TD>";

echo "<TD>".$row['city']."</TD>";

echo "<TD>".$row['state']."</TD>";

echo "<TD><a href='http://".$row['web']."' target='_blank'>web page</a></TD>";  //??Unless empty!

echo "</TR>";

}

echo "</TABLE>";

Link to comment
https://forums.phpfreaks.com/topic/195561-empty-results-in-mysql_fetch_array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.