Jump to content

JAM14

New Members
  • Posts

    2
  • Joined

  • Last visited

JAM14's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've worked on this the entire night. Finally, after two weeks, I came up with these codes: <?php if(@$_POST['submit']) { $select_paragraph=mysql_query('SELECT * FROM dependency'); $questrows = 0; while(mysql_fetch_array($select_paragraph)) { $counter = 0; $select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"'); $rows = mysql_num_rows($select_question); while($counter < $rows){ echo "<br>"; @$b=$_POST['Option'.$questrows]; $s="insert into temp(StudId, TestId, ItemId, LiteralId, Choice) values(1, 3, $questrows,'','$b')"; mysql_query($s); $counter++; $questrows++; } } header("Location: validate.php"); } ?> It solved my problem. @blacknight: Thanks anyway for the help.
  2. Hi. I'm having a problem regarding my codes involving radio buttons and subloop. I couldn't retrieve the data from post and I can't insert them to the database. I just couldn't find the error. Here's my form's code: <form method="post"> <?php $select_paragraph=mysql_query('SELECT * FROM dependency'); $questrows = 0; while($get_paragraph = mysql_fetch_array($select_paragraph)) { $TestID = $get_paragraph['testId']; $Dependid = $get_paragraph['DependencyId']; echo" <table border='1'> <tr class='classheader1'> <td align='center' class='paragraph'>". $get_paragraph['Situation']. "</td> <table>"; $select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"'); while($get_question = mysql_fetch_array($select_question)) { echo $LitId = $get_question['LiteralId']; echo $ItemID = $get_question['ItemId']; echo" <tr><td align='left' class='paragraph'><br>". $get_question['Question']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option1']. "'>". $get_question['Option1']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option2']. "'>". $get_question['Option2']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option3']. "'>". $get_question['Option3']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option4']. "'>". $get_question['Option4']. "</td></tr> "; echo "Radio Names = Option".$questrows." "; $questrows++; } echo" </table> </td> </tr> </table> "; } ?> <input type="submit" name="enter" value="Submit"/> </form> And here's the code where I retrieve the post so I could insert them into my database: <?php if(@$_POST['enter']) { $select_paragraph=mysql_query('SELECT * FROM dependency'); $questrows = 0; while($get_paragraph = mysql_fetch_array($select_paragraph)) { $TestID = $get_paragraph['testId']; $Dependid = $get_paragraph['DependencyId']; $select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"'); while($get_question = mysql_fetch_array($select_question)) { echo "Hi".@$option=$_POST['Option'.$questrows]; echo "<br>LitId = ".$LitId = $get_question['LiteralId']; echo "<br>ItemId = ".$ItemID = $get_question['ItemId']; echo '<br>ThisOption'.$questrows; $insertToTemp="insert into temp(StudId, TestId, ItemId, LiteralId, Choice) values(1, 3, $ItemID,$LitId,'$option[$questrows]')"; mysql_query($insertToTemp); $questrows++; echo "<br>"; } } } ?> Hope you could help me find the error. Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.