xionhack Posted May 6, 2010 Share Posted May 6, 2010 Hello. I have a huge confusion on how to do this. I have two tables Members: member_id, first_name, last_name Studies: study_id, study_name, member_id, times_studied, understanding Then I have a table in html, where I ask to fill choose from many studies, if the person did that study, how many times have that person studied, and if that person understood. My problem is that I dont know how to do the function in order for it to save the values in the correct way. Im going to show some code to show an example. <form action="whatever.php" method="post"> <table> <tr> <td>Study Name</td> <td>Studied?</td> <td>Times Studied</td> <td>Understanding</td> </tr> <tr> <td>Study 1</td> <td><input type="checkbox" name="?" value="?" /></td> <td><select name="?"> <option name="?" value="?">1</option> <option name="?" value="?">2</option> <option name="?" value="?">3</option> <option name="?" value="?">4</option> </select></td> <td><select name="?"> <option name="?" value="?">Understood</option> <option name="?" value="?">Didnt Understand</option> <option name="?" value="?">Needs Review</option> </select></td> </tr> <tr> <td>Study 2</td> <td><input type="checkbox" name="?" value="?" /></td> <td><select name="?"> <option name="?" value="?">1</option> <option name="?" value="?">2</option> <option name="?" value="?">3</option> <option name="?" value="?">4</option> </select></td> <td><select name="?"> <option name="?" value="?">Understood</option> <option name="?" value="?">Didnt Understand</option> <option name="?" value="?">Needs Review</option> </select></td> </tr> <tr> <td>Study 3</td> <td><input type="checkbox" name="?" value="?" /></td> <td><select name="?"> <option name="?" value="?">1</option> <option name="?" value="?">2</option> <option name="?" value="?">3</option> <option name="?" value="?">4</option> </select></td> <td><select name="?"> <option name="?" value="?">Understood</option> <option name="?" value="?">Didnt Understand</option> <option name="?" value="?">Needs Review</option> </select></td> </tr> etc.... </table> </form> When I have to submit this form, I already have the member_id that will be stored with these values. If it was only 1 line I could do it easily, but because there are so many, i really dont know how to do it. If somebody can, please help me!! Link to comment https://forums.phpfreaks.com/topic/200956-submit-lessons/ Share on other sites More sharing options...
siric Posted May 7, 2010 Share Posted May 7, 2010 There are loads of examples on forms and what the different components do that you can Google. eg http://www.tizag.com/phpT/examples/formvar.php and http://www.phpf1.com/tutorial/php-form.html I assume that you are not sure what to put in the areas that you have the question marks. You must give each form field a name and a value which will be captured once you submit the form. In the case of the selects, you don't really need the option name as the select name will be used. <td><input type="checkbox" name="studied" value="yes" /></td> <td><select name="times"> <option>1</option> <option>2</option> <option>3</option> <option value="4">4</option> </select></td> If the value being displayed in the dropdown box is the value that you want to pass to the action script, you do not even need the value, so the 3rd and 4th option will do the same thing. Once the form is submitted, the script that is called will extract the values by using $studied = $_POST['studies']; $times = $_POST['times'] Link to comment https://forums.phpfreaks.com/topic/200956-submit-lessons/#findComment-1054413 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.