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 Quote Link to comment 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 Quote Link to comment 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. 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.