gwolff2005 Posted April 23, 2009 Share Posted April 23, 2009 Hi guys, I need urgently your help. I am developing a psychological test. The users are logging onto a site from there is a link to the test page. The mysql database contains the following columns: id int(11) No username var(20) No password varchar(20) No firstname varchar(30) No resultspo char(2) No resultsm char(2) No resultspassion char(3) No The user fills out the form and then presses the button. NOW How can I do the following. As you can see below in the code, the answers of the questions need to be saved to different rows of the current user. In this case the answer of question numer one needs to be ADDED to the already existing value of row resultspo in mysql, question two needs to be added to the value of resultsmo in mysql, as well as number three needs to be added then to resultsmo. After adding all the values, the page needs to go to the next page which is call passiontest2. Please help. How can I do that??? Thanks! <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Your Passion Test</title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000033; } .style3 {font-family: Verdana, Arial, Helvetica, sans-serif} .style4 { font-size: 20px; color: #996600; } --> </style> </head> <body> <form id="form1" name="form1" method="post" action=""> <table width="699" border="0" align="center" cellspacing="5" class="style1"> <tr> <td colspan="3"><div align="center"><span class="style4">Your Passion Test</span></div></td> </tr> <tr> <td width="24"> </td> <td width="429"> </td> <td width="220"><div align="right">Saturday, 03/28/09</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right"><?php echo $_SESSION['MM_firstname']; ?></div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right"></div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>1</td> <td><strong>I like talking to people. </strong><br /> </b></td> <td><div align="left"> <input name="po1" type="radio" value="0" /> 0 <input name="repo1" type="radio" value="1" /> 1 <input name="po1" type="radio" value="2" /> 2 <input name="po1" type="radio" value="3" /> 3 <input name="po1" type="radio" value="4" /> 4 <input name="po1" type="radio" value="5" /> 5</div></td> </tr> <tr> <td>2</td> <td>It is important for me what other people think. </td> <td><p> <label></label> <label></label> <input name="mo2" type="radio" value="0" /> 0 <input name="remo2" type="radio" value="1" /> 1 <input name="mo2" type="radio" value="2" /> 2 <input name="mo2" type="radio" value="3" /> 3 <input name="mo2" type="radio" value="4" /> 4 <input name="mo2" type="radio" value="5" /> 5<br /> <br /> </p></td> </tr> <tr> <td>3</td> <td class="style1">My level of excitement is high right now. </td> <td><p> <label></label> <input name="mo3" type="radio" value="0" /> 0 <input name="mo3" type="radio" value="1" /> 1 <input name="mo3" type="radio" value="2" /> 2 <input name="mo3" type="radio" value="3" /> 3 <input name="mo3" type="radio" value="4" /> 4 <input name="mo3" type="radio" value="5" /> 5<br /> </p></td> </tr> <tr> <td>4</td> <td>I like solving mathematical tasks. </td> <td><input name="po4" type="radio" value="0" /> 0 <input name="po4" type="radio" value="1" /> 1 <input name="po4" type="radio" value="2" /> 2 <input name="po4" type="radio" value="3" /> 3 <input name="po4" type="radio" value="4" /> 4 <input name="po4" type="radio" value="5" /> 5</td> </tr> </table> <p align="center"> <input name="Submit" type="submit" class="style1" value="go on" /> </p> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
revraz Posted April 23, 2009 Share Posted April 23, 2009 You need to UPDATE the table. UPDATE `tablename` SET resultspo = '$answer1' WHERE id = $id You just need to grab the variables from the form to populate the query. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 23, 2009 Share Posted April 23, 2009 because he's wanting to append the fields, not overwrite, he needs to use CONACT(): UPDATE `my_table` SET `my_field` = CONACT(`my_field`, ',addsomethinghere'); Quote Link to comment Share on other sites More sharing options...
gwolff2005 Posted April 23, 2009 Author Share Posted April 23, 2009 Hi Jonsja, so you mean, I cannot update i, because then it would be overwritten...? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.