imarockstar Posted July 10, 2009 Share Posted July 10, 2009 I have a page where I need to count the rows of multiple tables .... which I have working fine .. I was just wandering if there was a shortcut to doing this .. I have 3 tables right now .. but before this is over I will probably have about 30 or so ... this is what I have as of right now .. <?php $sql="SELECT * FROM gq_answers WHERE userid = '$userid' "; $result2=mysql_query($sql); $count=mysql_num_rows($result2); if($count >= 1){ echo "<a href=''>General Questions</a> <br>"; }; $sql="SELECT * FROM edu_answers WHERE userid = '$userid' "; $result3=mysql_query($sql); $count=mysql_num_rows($result3); if($count >= 1){ echo "<a href=''>Education Questions</a>"; }; $sql="SELECT * FROM emp_answers WHERE userid = '$userid' "; $result4=mysql_query($sql); $count=mysql_num_rows($result4); if($count >= 1){ echo "<a href=''>Education Questions</a>"; }; ?> is there a way to put the above in a loop or somthing ? thanks b Link to comment https://forums.phpfreaks.com/topic/165506-help-with-a-loop-question/ Share on other sites More sharing options...
Maq Posted July 10, 2009 Share Posted July 10, 2009 Why don't you just select them all in a single query? Link to comment https://forums.phpfreaks.com/topic/165506-help-with-a-loop-question/#findComment-872907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.