Jump to content

rags_asr

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rags_asr's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php $query = "Select * from users where username = '$user' "; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $test = $_POST['test1']; $ques = "Select * from questions where testname = '$test' "; $qres = mysql_query($ques) or die(mysql_error()); $qdetails = mysql_fetch_array($qres); $id = $qdetails['id']; $testname = $qdetails['testname']; $ans = "Select * from answers where qid = $id"; $ares = mysql_query($ans) or die(mysql_error()); if($qdetails) { ?> <div class="padding"> <form name="answerform" action="answer.php" method="POST"> <h3> </h3> <input name="test2" id="test2" type="text" value="<?php echo $qdetails['testname'];?>" /><h3><?php echo $qdetails['text'];?></h3> <input name="test3" id="test3" type="text" value="<?php echo $qdetails['testseries'];?>" /><h3><?php echo $qdetails['text'];?></h3> <br /> <br /> <br /> <?php while($opdetails = mysql_fetch_assoc($ares)) { ?> <input class="text" id="opt2" name="correctans" type="radio" value="<?php echo $opdetails['text']; ?>" /><br /><?php echo $opdetails['text']; ?> <?php }?> <div class="two-fields clearfix". <p class="confirm"> </p> </div> <input type="submit" value="SUBMIT ANSWER" /> </form> </div> </div> </div> <?php } this is the code for the program where i am creating the fields i want to fetch the data from the input fields with the name test 2 and test 3 in answer.php $query = "Select score from users where username = '$user' "; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $user_score = $row['score']; print_r($_REQUEST); $tester = $_POST['test3']; $test = $_POST['test2']; print_r($_POST); var_dump($_POST); $ques = "Select * from questions where testname = '$test' And testseries = '$tester' "; $result = mysql_query($ques) or die(mysql_error()); $row = mysql_fetch_array($result); $qid = $row['id']; $score = $row['score']; if(isset($_POST['correctans'])) { $answer = $_POST['correctans']; } else { $answer = ''; } $fetch_ans = "Select * from answers where correct = 1 AND qid = $qid"; $result = mysql_query($fetch_ans) or die(mysql_error()); $row = mysql_fetch_array($result); $id = $row['id']; $correctans = $row['text']; if('$correctans' == '$answer') { $user_score += $score; $qid++; $query = "Update users set score = $user_score where username = '$user'"; $res = mysql_query($query) or die(mysql_error()); if($res) { header("Location: answer.php"); } }else { header("Location: answer.php"); } ?> THIS IS answer.php and here i try to post information from test2 and test3 fields but i am not getting any output the output shows blank array() and unidentified index test2 and unidentified index test3 i am not able to figure out the error any help will be highly appreciated and forgive me if i have made any mistakes in posting the question since i am a newbie at PHPFREAKS
  2. i dnt have any knowledge of ajax...can u help me with it?
  3. hii,everyone... i am new to the forum ..so forgive me if i make some errors in describing my problem i want to create a drop down menu...the values of which i want to retrieve from a table i have created in my database... i have been able to acheive this...but i want a second drop down menu...in which i want the values to get filtered according to the selection of the first drop down menu... i hav a table with the name test...which i am connecting to the first drop down menu i hav created another table with the name testtype...for second menu.. the id of first table is the testid of second... plzz help me with creating the second menu... my code is <?php $sql_result = "select test_series FROM test"; $result = mysql_query($sql_result); ?> <td>Select Test Series </td> <td> <select name="testseries" id="testseries" )"> <option>Select</option> <?php if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $test = $row['test_series'];?> <option><?php echo $test ?></option> <?php } } else {?> <option>No Names Present</option>"; <?php } ?> </select> </td> </tr> <tr> <?php $testseries = $_POST['testseries']; $query = "select id from test where test_series = '$testseries'"; $resultt = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($resultt); $id = $row['id']; $sql_result = "select test_name FROM testtype where testid = $id"; $result = mysql_query($sql_result); ?> <td>Select Test Name </td> <td> <select name="testtype"> <option>Select</option> <?php if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $test2 = $row['test_name'];?> <option><?php echo $test2 ?></option> <?php } } else {?> <option>No Names Present</option>"; <?php } ?> </select> </td> </tr> IN THIS CODE I AM GETTIN AN ERROR Undefined index: testseries in ..addques.php on line 155 WHICH IS THIS ONE $testseries = $_POST['testseries'];
×
×
  • 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.