Jump to content

help with a loop question ...


imarockstar

Recommended Posts

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

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.