hansman Posted August 7, 2008 Share Posted August 7, 2008 Hello all, I have about 5 tables in a database that stroe pictures. I want to have one page where all the pictures come out. This is my code. $query = "SELECT * FROM Wood_Destroying_Insects"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<img src='saveimg.php?id=".$row['id']."'/>"; ideas? Quote Link to comment Share on other sites More sharing options...
deadlyp99 Posted August 7, 2008 Share Posted August 7, 2008 Just add these: Note: Of course you can get tricky and use arrays to make the code more compact, but its not neccisarrily needed. I believe you can use sql joins, but I havn't quite figured those out, but might as well experiment. $query = "SELECT * FROM Wood_Destroying_Insects"; $query2 = "SELECT * FROM 2"; $query3 = "SELECT * FROM 3"; $query4 = "SELECT * FROM 4"; $query5 = "SELECT * FROM 5"; $result = mysql_query($query) or die(mysql_error()); $result2 = mysql_query($query2) or die(mysql_error()); $result3 = mysql_query($query3) or die(mysql_error()); $result4 = mysql_query($query4) or die(mysql_error()); $result5 = mysql_query($query5) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<img src='saveimg.php?id=".$row['id']."'/>"; } while($row = mysql_fetch_array($result2)){ echo "<img src='saveimg.php?id=".$row['id']."'/>"; } while($row = mysql_fetch_array($result3)){ echo "<img src='saveimg.php?id=".$row['id']."'/>"; } while($row = mysql_fetch_array($result4)){ echo "<img src='saveimg.php?id=".$row['id']."'/>"; } while($row = mysql_fetch_array($result5)){ echo "<img src='saveimg.php?id=".$row['id']."'/>"; } Quote Link to comment Share on other sites More sharing options...
hansman Posted August 7, 2008 Author Share Posted August 7, 2008 for some wacky reason im only getting results from number query 3 Quote Link to comment Share on other sites More sharing options...
laconica Posted August 7, 2008 Share Posted August 7, 2008 I have had some strange results with using $row more than once I always name them different eg $row=mysql_query($query) ; $row2=mysql_query($query2) ; My problems then stopped Quote Link to comment Share on other sites More sharing options...
trq Posted August 7, 2008 Share Posted August 7, 2008 There is a tutorial on our main site covering sql JOINS, I suggest you read it. The aboive method is rediculously inificient. 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.