Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Help php :(

iamGermel

Apprentice
Advanced Member
Messages
67
Reaction score
0
Points
26
so eto yung prob ko mga, boss..

ayaw kasi kunin yung mga inputs ko sa questions, answer 1,2,3,4 at correct answer.. pero pag click ko nung save, na-sasave yung ibang input ko bukod dun sa questions, answer 1,2,3,4 at correct answer

eto po yung screenshot ng code ko..









at eto po yung result pagka-click ko nung SAVE button:




maraming salamat po sa tulong :pray: :pray: :pray:
 
Last edited:
so eto yung prob ko mga, boss..

ayaw kasi kunin yung mga inputs ko sa questions, answer 1,2,3,4 at correct answer.. pero pag click ko nung save, na-sasave yung ibang input ko bukod dun sa questions, answer 1,2,3,4 at correct answer

eto po yung screenshot ng code ko..

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/1_zpsbw7i0gig.jpg[/URL]

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/2_zpsvejqdeyk.jpg[/URL]

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/3_zpsmarv4tjw.jpg[/URL]



at eto po yung result pagka-click ko nung SAVE button:

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/4_zpsvxfjktxx.jpg[/URL]


maraming salamat po sa tulong :pray: :pray: :pray:

Post mo yung CODE mo hindi screenshots
 
so eto yung prob ko mga, boss..

ayaw kasi kunin yung mga inputs ko sa questions, answer 1,2,3,4 at correct answer.. pero pag click ko nung save, na-sasave yung ibang input ko bukod dun sa questions, answer 1,2,3,4 at correct answer

eto po yung screenshot ng code ko..

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/1_zpsbw7i0gig.jpg[/URL]

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/2_zpsvejqdeyk.jpg[/URL]

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/3_zpsmarv4tjw.jpg[/URL]



at eto po yung result pagka-click ko nung SAVE button:

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/4_zpsvxfjktxx.jpg[/URL]


maraming salamat po sa tulong :pray: :pray: :pray:

nakahiwalay kasi ng form ung button mo .
 
pasensya na po sa screenshot... eto po yung ginamit kong code:

<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';
}

}

?>
 
pasensya na po sa screenshot... eto po yung ginamit kong code:

na try mo na ba ung cnbi ko .





if(isset($_POST['confirm'])){

$MC = $_POST['MC'];
echo "<form method = 'POST' name = 'items' actions ='createquestions.php'>";
$items = 1;

for ($x = 1; $x <= $MC; $x++) {

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 "<input type ='submit' name = 'save' value = 'Save'>";
echo "</form>";

}
 
pasensya na po sa screenshot... eto po yung ginamit kong code:



typo ka ba dto o eto tlga code mo?

change this one :
echo "<form metod = 'POST' action = 'createquestions.php'>";

to this:
echo "<form method = 'POST' action = 'createquestions.php'>";



tama si putikKoe.


etong code na to : echo "<input type ='submit' name = 'save' value = 'Save'>";

is pasok mo dto:


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++;
(dito) echo "<input type ='submit' name = 'save' value = 'Save'>";
echo "</form>";

}
 
na try mo na ba ung cnbi ko .





if(isset($_POST['confirm'])){

$MC = $_POST['MC'];
echo "<form method = 'POST' name = 'items' actions ='createquestions.php'>";
$items = 1;

for ($x = 1; $x <= $MC; $x++) {

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 "<input type ='submit' name = 'save' value = 'Save'>";
echo "</form>";

}


na try ko na sya, boss at yung huling input lang yung sine-save nya..
ganito yung nangyari..

pagka input ko ng 2 dito sa code na to
Multiple Choice: <input type = "text" name="MC"><br>
<input type = "submit" name = "confirm" value = "Confirm">

gumawa sya ng set of questions/answers dalawa dahil dun sa inayos nyong code, which is eto:

if(isset($_POST['confirm'])){

$MC = $_POST['MC'];
echo "<form method = 'POST' name = 'items' actions ='createquestions.php'>";
$items = 1;

for ($x = 1; $x <= $MC; $x++) {

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 "<input type ='submit' name = 'save' value = 'Save'>";
echo "</form>";

}

ngayon, boss.. ang na-sasave nya lang ay yung mga input ko na questions at answers sa number 2.. d nya na-save yung mga input ko sa number 1



- - - Updated - - -

ah, typo lang ako nyan boss pasensya na.. sinunod ko rin yung mga suggestions nyo
 
na try ko na sya, boss at yung huling input lang yung sine-save nya..
ganito yung nangyari..

pagka input ko ng 2 dito sa code na to


gumawa sya ng set of questions/answers dalawa dahil dun sa inayos nyong code, which is eto:



ngayon, boss.. ang na-sasave nya lang ay yung mga input ko na questions at answers sa number 2.. d nya na-save yung mga input ko sa number 1

[url]http://i1007.photobucket.com/albums/af198/Smokey51043/Untitled_zpsfweglmra.jpg[/URL]

- - - Updated - - -

ah, typo lang ako nyan boss pasensya na.. sinunod ko rin yung mga suggestions nyo


kasi naka for loop ang form at same sila ng name . di nmn nka array ang name pag ung $_POST mo pagka save ndi din array . isa lang tlga ang kukunin nya jan . google mo paano ma array ng form name at php variables
 
Back
Top Bottom