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>"; Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
jmeulemans Posted March 17, 2010 Author Share Posted March 17, 2010 Thank you so much!!!!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.