guestabc Posted September 12, 2010 Share Posted September 12, 2010 Hi I need a bit of help with a for loop nested within another for loop. SQL Query of Questions For Loop { Output Data SQL Query Of Possible Answers [i]Output answer image here[/i] For Loop { Output Data } } The above is simple and I have the data displaying as I want it however I now want to output an image that relates to the second SQL query (answers), but I only need one image to output per question. The problem comes that I am accessing the mysql_fetch_array inside the second for loop meaning that I have to output the image inside this loop, but this means all images will be output? I hope it is clear to you what I am trying to do here and thanks for any help in advance! Quote Link to comment https://forums.phpfreaks.com/topic/213233-php-for-loop/ Share on other sites More sharing options...
harristweed Posted September 12, 2010 Share Posted September 12, 2010 //SQL Query of Questions $image_displayed=0; //For Loop { // Output Data // SQL Query Of Possible Answers if($image_displayed==0){ [i]Output answer image here[/i] $image_display++; } For Loop { Output Data } } Quote Link to comment https://forums.phpfreaks.com/topic/213233-php-for-loop/#findComment-1110308 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.