Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL to a Formula on a webbpage

Status
Not open for further replies.

grindange

Programmer
Jul 19, 2004
18
SE
I work with Perl, CGI, MySQL and HTML....
A user have answer some question in a quiz at my site. The user want to change his answer. How can I get the users answer from the database back to the formula (pickboxes and radiobuttons), so he can change question 8 from "A" to a "B" and then save it back to a database?

/ Marcus
 
you store which one he checked, right? so show him the question again, mark the one currently checked and let him choose another


Bastien

Cat, the other other white meat
 
Yes the code should look at the stuff in the database and make the decision on what value is required and when you generate the code set the checked attribute or selected attribute as appropriate
 
Thanks for answer, but I would appreciate to know how to get the the data from the database back to the webbpage. E.g. How will answer C be checked into question number 3??

/ Marcus
 
ok, suppose you have a row in the database with a key of question 8 and a value set to A because that was your user did yesterday.
He now wants to change it, so you run a php page and you run a query like select answer from question where question=8;
fetch the value into a variable using your favourite command, well put it into a variable called $answer8
To cut a long story short when you get to the part of the php which needs to generate the line for question 8 have something like:
Code:
<input type=radio name=question8 value=A
 <?php if ($answer8 == "A") echo " checked"?>
>A
<input type=radio name=question8 value=B
 <?php if ($answer8 == "B") echo " checked"?>
>B
is this of any use ?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top