Jump to content

neoxmel

New Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About neoxmel

  • Rank
    Newbie
  1. Thank you so much for the help and suggestion, guys. I will make sure to take application on what you have taught me ! The flow of this program is that i want the user to input how many questions he/she would like to create and the system would automatically generate the inputted questions along with the answers. So, i ended up using this loop: for ($x = 1; $x <= $MC; $x++) { echo "<form metod = 'POST' action = 'createquestions.php'>"; echo "Question Number $items:"; echo "<input type = 'text' name = 'questions' style='width: 500px'><br><br>"; echo "A. "; echo "<input type = 'text' name = 'ans1'>"; echo "B. "; echo "<input type = 'text' name = 'ans2'><br>"; echo "C. "; echo "<input type = 'text' name = 'ans3'>"; echo "D. "; echo "<input type = 'text' name = 'ans4'><br>"; echo "Correct Answer: "; echo "<input type = 'text' name ='cans'><br><br>"; $items++; echo "</form>"; } I know i have a lot of things to work with, but i'm planning to get this function first before designing the page.
  2. <form method = "POST" name = "subjects" action ="createquestions.php"> Select Subject: <select name = "subjects"> <option value="English">English</option> <option value="Math">Math</option> <option value="Science">Science</option> <option value="Filipino">Filipino</option> </select> <br> Multiple Choice: <input type = "text" name="MC"><br> <input type = "submit" name = "confirm" value = "Confirm"> <a href = "home.php"><span>Cancel</span></a></center> </form> <?php if(isset($_POST['confirm'])){ $MC = $_POST['MC']; echo "<form method = 'POST' name = 'items' actions ='createquestions.php'>"; $items = 1; echo "</form>"; for ($x = 1; $x <= $MC; $x++) { echo "<form metod = 'POST' action = 'createquestions.php'>"; echo "Question Number $items:"; echo "<input type = 'text' name = 'questions' style='width: 500px'><br><br>"; echo "A. "; echo "<input type = 'text' name = 'ans1'>"; echo "B. "; echo "<input type = 'text' name = 'ans2'><br>"; echo "C. "; echo "<input type = 'text' name = 'ans3'>"; echo "D. "; echo "<input type = 'text' name = 'ans4'><br>"; echo "Correct Answer: "; echo "<input type = 'text' name ='cans'><br><br>"; $items++; echo "</form>"; } echo "<form method = 'POST' action = 'createquestions.php'>"; echo "<input type ='submit' name = 'save' value = 'Save'>"; echo "</form>"; } ?> <?php if(isset($_POST['save'])){ $user_id = $_SESSION['id']; $questions = $_POST['questions']; $ans1 = $_POST['ans1']; $ans2 = $_POST['ans2']; $ans3 = $_POST['ans3']; $ans4 = $_POST['ans4']; $cans = $_POST['cans']; require_once('xcon.php'); $query = "INSERT INTO mcq (mc_id, mc_num, user_id, questions, ans1, ans2, ans3, ans4, cans) VALUES ('NULL','$items','$user_id','$questions','$ans1','$ans2','$ans3','$ans4','$cans')"; $result = mysql_query($query); if($result){ echo 'Insert Success!'; } else{ echo 'Error'; } } ?> I am so sorry for posting the screenshot.. actually, those codes are all in one form and this is the full code that i have
  3. Hello, guys ! i'm new in this forum and i seem to have a little problem in coding and i would really appreciate your help. Here's my problem.. the values in QUESTIONS, ANS1, ANS2, ANS3, ANS4, CANS, ITEMS werent read, hence, it was not saved in the database.. but the other values were saved! now, i got confused.. here's the image of my code: and here's the result after clicking the SAVE button:
×
×
  • 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.