unknown101 Posted April 14, 2008 Share Posted April 14, 2008 Hi Guys, I have the following code: while ($row = mysql_fetch_array($match_genres)) { $matching_genres = $row['Artist']; $get_artist_ID = $row['Artist_ID']; //Check we have the ID echo $get_artist_ID; $get_artist_tracks =mysql_query("select Track from track_tbl where Artist_ID='$get_artist_ID'") or die ('Error: '.mysql_error ()); while ($result = mysql_fetch_array($get_artist_tracks)); { $returned_tracks = $result['Track']; echo "$matching_genres<br><p>"; echo $returned_tracks; } } Everything works fine until I add in the nested while loop? If for example I just use $result = mysql_fetch_array($get_artist_tracks); without a loop I get the first row returned from the database no problems. I then add the loop incase there are other entries with the same "Artist_ID" and attempt to echo them, but it only then prints the artist_ID and $matching_genres ? Can anyone tell me where im going wrong? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/101029-looping-through-results/ Share on other sites More sharing options...
Pioden Posted April 14, 2008 Share Posted April 14, 2008 I don't think you can have a query within the result of another query ... Not to the best of my knowledge anyway. If someone says different I'll be very interested!! Huw Link to comment https://forums.phpfreaks.com/topic/101029-looping-through-results/#findComment-516639 Share on other sites More sharing options...
fenway Posted April 14, 2008 Share Posted April 14, 2008 Post both queries (I only see one), and the table structure -- a JOIN should be able to do this. Link to comment https://forums.phpfreaks.com/topic/101029-looping-through-results/#findComment-516727 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.