Below I have 2 queries, one query looking a details for each question (such as question content, answers, number of marks etc) and the other query is too look for images within each question. I have set up arrays for each data stored in each row for both queries:Question Details query:\[code\]$qandaquery = "SELECT q.QuestionContent, GROUP_CONCAT( DISTINCT Answer ORDER BY Answer SEPARATOR ' ' ) AS Answer, FROM Question q LEFT JOIN Answer an ON q.QuestionId = an.QuestionId WHERE SessionId = ? GROUP BY q.QuestionId ORDER BY q.QuestionId";global $mysqli;$qandaqrystmt = $mysqli->prepare($qandaquery);// You only need to call bind_param once$qandaqrystmt->bind_param("i", $_POST["session"]);// get result and assign variables (prefix with db)$qandaqrystmt->execute();$qandaqrystmt->bind_result($qandaQuestionContent, $qandaAnswer);$arrQuestionContent = array();$arrAnswer = array();while ($qandaqrystmt->fetch()) { $arrQuestionContent[] = $qandaQuestionContent; $arrAnswer[] = $qandaAnswer;}$qandaqrystmt->close();\[/code\]Image Details for Each question query:\[code\]$imgquery = "SELECT s.SessionId, q.QuestionId, i.ImageId, ImageFile FROM Session s INNER JOIN Question q ON s.SessionId = q.SessionId INNER JOIN Image_Question iq ON q.QuestionId = iq.QuestionId INNER JOIN Image i ON iq.ImageId = i.ImageId WHERE s.SessionId = ?";global $mysqli;$imgqrystmt = $mysqli->prepare($imgquery);// You only need to call bind_param once$imgqrystmt->bind_param("i", $_POST["session"]);// get result and assign variables (prefix with db)$imgqrystmt->execute();$imgqrystmt->bind_result($imgSessionId, $imgQuestionId, $imgImageId, $imgImageFile);$arrImageFile = array();while ($imgqrystmt->fetch()) { $arrImageFile[] = $imgImageFile;}$imgqrystmt->close();\[/code\]Now what I am trying to do is store the details into a table. Now the Question and Answers from the first query and set of arrays store in the table with no problems. But I am getting no output when trying to store the images for each question. A question can have no images, one image or multiple images. My question is how can I get the Image column to show, outputting the list of images for each question?Below is the table output details:
My question is that I am doing something wrong for images not to appear for each question. How can the table and arrays be set up to display images for each question?Below is code for my table:\[code\]<table id="tableqanda" align="center" cellpadding="0" cellspacing="0"> <thead> <tr> <th width="30%" class="question">Question</th> <th width="8%" class="answer">Answer</th> <th width="12%" class="images">Images</th> </tr> </thead></table><div id="tableqanda_onthefly_container"> <table id="tableqanda_onthefly" align="center" cellpadding="0" cellspacing="0"> <tbody> <?php foreach ($arrQuestionContent as $key=>$question) { echo ' <tr class="tableqandarow">'.PHP_EOL; echo ' <td width="30%" class="question">'.htmlspecialchars($question).'</td>' . PHP_EOL; echo ' <td width="8%" class="answers">'.htmlspecialchars($arrAnswer[$key]).'</td>' . PHP_EOL; foreach ($arrImgQuestionId as $key=>$img) { echo ' <td width="12%" class="images">'.htmlspecialchars($arrImageFile[$key]).'</td>' . PHP_EOL; } echo '</tr>'.PHP_EOL; } ?></tbody> </table></div>\[/code\]