jmeulemans Posted March 17, 2010 Share Posted March 17, 2010 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 More sharing options...
FD_F Posted March 17, 2010 Share Posted March 17, 2010 example: if(!empty($row['web'])) { echo "<TD><a href='http://".$row['web']."' target='_blank'>web page</a></TD>"; } echo will only run if $row['web'] not empty Link to comment https://forums.phpfreaks.com/topic/195561-empty-results-in-mysql_fetch_array/#findComment-1027566 Share on other sites More sharing options...
jmeulemans Posted March 17, 2010 Author Share Posted March 17, 2010 Thank you so much!!!!!!! Link to comment https://forums.phpfreaks.com/topic/195561-empty-results-in-mysql_fetch_array/#findComment-1027569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.