hi
i want to insert user selected option value in the database
i have wrote the following script
$query = "insert into codes VALUES ('','". $_SESSION['quiz_data'][$i]['option3']."','".$_SESSION['quiz_grade']."')"; $sql = mysql_query($query);?>
i can do manual insertion but i want to insert user response
If you are wanting to put the selected radio button use something like this perhaps.
if (isset($_POST['radiobutton'])) {
$selected_radio = $_POST['radiobutton'];
}
//create a new mysql column for insertion
INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...WHERE username='$username');
INSERT INTO only works the first time, after that you have to use a mysql update query.
$result = mysql_query("UPDATE column SET radio='$radiovalue' WHERE username='$username'") or die(mysql_error());
mattibutt
ASKER
hi
thanks for getting back i don't want to get all the values i only want the selected value of radio button and each record will be different
mattibutt
ASKER
these are option values when user select one and click on the button then i want to write the selected value inside the table
hi Unspoken1
i think i have not explained to you properly what i want to acheive
i have a quiz which may have 10 questions in each quiz
the user will respond to each question and each question answer will be stored in the database
for instance if user has taken 10 questions then the ten different records will be inserted in the database
something like this
quizid questionid userresponse
right now i am stuck because i am not able to get the post value for each question i have tried it several different things but it doesn't work
so all i want to be able to do is
insert each question response as a seperate record
thanks
mattibutt
ASKER
sorry but i didnt get any help from you
Unspoken1
do you have access to phpmyadmin? create a different column...
use post like this
$_['POST']['htmlnamehere'];
I wrote the post wrong. $_POST['radiobutton'];
... If you are unable to get the $_POST vars in your php script you need to make sure your html input tags have the name attribute... this is what is used to name the post variable when the form is submitted.
if (isset($_POST['radiobutton
$selected_radio = $_POST['radiobutton'];
}
//create a new mysql column for insertion
INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...WHERE username='$username');
INSERT INTO only works the first time, after that you have to use a mysql update query.
$result = mysql_query("UPDATE column SET radio='$radiovalue' WHERE username='$username'") or die(mysql_error());