misterm0ntana Posted January 3, 2010 Share Posted January 3, 2010 Hi, I'm busy with a photoshop contest script but now i'm stuck Here is what i want to do I have a contest sql table and a imgreg table and now i want to show the imgreg pictures with the same cid as the contest id this is what i got: <? $query = "SELECT * FROM contest"; $pic = mysql_query($query); while($row = mysql_fetch_assoc($pic)) { $dbres = ("SELECT c.*, i.* FROM contest c LEFT JOIN imgreg i ON c.id = i.cid ORDER BY image_name") or die (mysql_error()); $result = mysql_query($dbres) or die (mysql_error()); while($foto = mysql_fetch_assoc($result)){ $thumb = "images/contest/" . $foto['image_name']; echo '  <img src="'.$thumb.'" alt="" width="150" height="150" />'; } } ?> Link to comment https://forums.phpfreaks.com/topic/187041-same-id/ Share on other sites More sharing options...
cags Posted January 4, 2010 Share Posted January 4, 2010 I'm not entirely sure why you are SELECTing all rows from the contest table then looping through them and on each loop SELECTing all the rows again but joining the images. I really don't think you need the outside loop. You don't really explain what exactly your question is, you simply state what your attempting to do and what you have tried. So I'm assuming that your code doesn't have the desired outcome? Can you clarify exactly what your issue is? My best guess is that there may be multiple entries in imgreg for each item in contest. That being the case you probably don't want a LEFT JOIN. Oh and can you please use code tags (the button with the # on it next to the quote/speech bubble). Thanks. Link to comment https://forums.phpfreaks.com/topic/187041-same-id/#findComment-988056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.