אני חושב שהבנתי את הבעיה
בתחילה את שולף את כל הנתונים ע"י לולאת while לתוך משתנה recordset. אחרי שסיימת לשלוף את הנתונים, ככל הידוע לי, המשתנה result סיים את תפקידו, ואין לו מה לעשות יותר. הנה הצעת התיקון שלי:
<?php // MySQL connection $link = mysql_connect(); if(!$link) die("Couldn't connect to MySQL"); mysql_select_db("southp",$link) or die("Couldn't open \"southp\": " .mysql_error()); $result = mysql_query("SELECT poll_questions.ID as QuestionID, poll_questions.Question as Question, poll_answers.ID as AnswerID, poll_answers.Answer as Answer FROM poll_questions, poll_answers WHERE poll_questions.ID = poll_answers.Question_ID AND poll_questions.Status=1"); $i = 0; while($recordset = mysql_fetch_array($result)) { $Question = $recordset['Question']; $QuestionID = $recordset['QuestionID']; $array1[$i][0] = $recordset['AnswerID']; $array1[$i][1] = $recordset['Answer']; } ?> <form name="Voting" method="post" action="PollVote.php"> <table border="0" cellspacing="0" cellpadding="0" width="260"> <tr> <td colspan="2" align="center"> <?=$Question\n?> <input type="hidden" name="QuestionID" value="<?=$QuestionID?>"> </td> </tr> <?php for($i = 0; $i < count($array1); $i++) { echo "<tr>"; echo "<td><input type=\"radio\" name=\"AnswerID\" value=\"{$array[$i][0]}\"></td>"; echo "<td>{$array[$i][1]}</td>"; echo "</tr>"; } ?> <tr> <td colspan="2" align="center"><br> <input type="submit" name="submit" value="ùìç" class="button"> </td> </tr> </table> </form> <?php // Close connection mysql_close($link); ?>
והנה גם הסבר: יצרתי מערך ששומר את הנתונים הנשלפים בלולאת ה-while. אחר כך, אי אפשר לנסות לשלופם מחדש בלולאת while דומה, משום שהנתונים כבר נשלפו. לכן במקום השתמשתי ב-for שמשתמש בנתונים שאוחסנו במערך כדי שלא יאבדו. מקווה שזה יעבוד