AV1611 Posted December 29, 2006 Share Posted December 29, 2006 this script shows the table even if there are no rows returned. How do I make the table not appear? I can't figure out how to make this if do while else or is there another way. I can only figure out how to fire the query twice, once as an if then again as a while but that seems quite lame...[code] echo "<center><table style='border-collapse:collapse; border-color:#999' border='1' cellpadding='5'><tr><td>GUID</td><td>NAME</td><td>LINK</td></tr>"; $result = mysql_query("SELECT `GUID`,`A`,`LISTER` from mbl_copy where `GUID` like '$q'"); while($row=mysql_fetch_array($result)){ echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>"; if ($row[2]=='AASA') { echo "<a href='http://appeals.aaserveradmins.com/index.php?guid=".$row[0]."&Submit=Submit'>".$row[2]."</a>"; } elseif ($row[2]=='AON') { echo "<a href='http://www.emailcart.net/airdale/index.php?detail=".$row[0]."&Submit=Submit'>".$row[2]."</a>"; } elseif ($row[2]=='ACI') { echo "<a href='http://blmservices.com/~osprey/aao/aci.php?GUID=".$row[0]."' target='_blank'>ACI</a>"; } elseif ($row[2]=='PsB') { echo "<a href='http://www.punksbusted.com/cgi-bin/membership/rpi.cgi?par=".$row[0]."' target='_blank'>PsB</a>"; } else { echo $row[2]; } echo "</td></tr>"; }echo "</table>";[/code] Link to comment https://forums.phpfreaks.com/topic/32187-solved-if-do-while-else/ Share on other sites More sharing options...
genericnumber1 Posted December 29, 2006 Share Posted December 29, 2006 mysql_num_rows()something like...[code]<?php $result = mysql_query("SELECT `GUID`,`A`,`LISTER` from mbl_copy where `GUID` like '$q'"); if(mysql_num_rows($result) != 0){ echo "<center><table style='border-collapse:collapse; border-color:#999' border='1' cellpadding='5'><tr><td>GUID</td><td>NAME</td><td>LINK</td></tr>"; while($row=mysql_fetch_array($result)){ echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>"; if ($row[2]=='AASA') { echo "<a href='http://appeals.aaserveradmins.com/index.php?guid=".$row[0]."&Submit=Submit'>".$row[2]."</a>"; } elseif ($row[2]=='AON') { echo "<a href='http://www.emailcart.net/airdale/index.php?detail=".$row[0]."&Submit=Submit'>".$row[2]."</a>"; } elseif ($row[2]=='ACI') { echo "<a href='http://blmservices.com/~osprey/aao/aci.php?GUID=".$row[0]."' target='_blank'>ACI</a>"; } elseif ($row[2]=='PsB') { echo "<a href='http://www.punksbusted.com/cgi-bin/membership/rpi.cgi?par=".$row[0]."' target='_blank'>PsB</a>"; } else { echo $row[2]; } echo "</td></tr>"; } echo "</table>"; }?>[/code]I might have typo'd something since the tabbing confused my sleep-deprived eyes, but you get the idea Link to comment https://forums.phpfreaks.com/topic/32187-solved-if-do-while-else/#findComment-149397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.