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? Link to comment https://forums.phpfreaks.com/topic/118620-select-from-mutiple-tables/ 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']."'/>"; } Link to comment https://forums.phpfreaks.com/topic/118620-select-from-mutiple-tables/#findComment-610681 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 Link to comment https://forums.phpfreaks.com/topic/118620-select-from-mutiple-tables/#findComment-610693 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 Link to comment https://forums.phpfreaks.com/topic/118620-select-from-mutiple-tables/#findComment-610737 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. Link to comment https://forums.phpfreaks.com/topic/118620-select-from-mutiple-tables/#findComment-610740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.