facarroll Posted October 18, 2010 Share Posted October 18, 2010 I don't know whether this is a PHP or an HTML question. I want to be able to post a preset value to accompany an input text value, and have both values entered in the database record. You can see in the code below that the form asks for names for up to six student groups, such as "Year7", "Year8", "Year9" and so on. What I want my form to do is to post the accompanying preset input name (in this case "group1", "group2", "group3", and so on) to a second column in the same record, so that I can search the records on this preset field. How can I do this? <table width="750" align="center" cellpadding="4"> <form action="admin_login.php" method="post" enctype="multipart/form-data"> <tr> <td><div align="right"><font size="-1">Student Group 1: </font><font color="#CC0000"> </font></div></td> <td><input name="group1" type="text" value="<?php echo "$group1"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 2: </font><font color="#CC0000"> </font></div></td> <td><input name="group2" type="text" value="<?php echo "$group2"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 3: </font><font color="#CC0000"> </font></div></td> <td><input name="group3" type="text" value="<?php echo "$group3"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 4: </font><font color="#CC0000"> </font></div></td> <td><input name="group4" type="text" value="<?php echo "$group4"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 5: </font><font color="#CC0000"> </font></div></td> <td><input name="group5" type="text" value="<?php echo "$group5"; ?>" /></td> </tr> <tr> <td><div align="right"><font size="-1">Student Group 6: </font><font color="#CC0000"> </font></div></td> <td><input name="group6" type="text" value="<?php echo "$group6"; ?>" /></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 18, 2010 Share Posted October 18, 2010 That doesn't make any sense. Why would you not simply store each value in a field named 'group1', 'group2', etc.? Quote Link to comment Share on other sites More sharing options...
Colton.Wagner Posted October 18, 2010 Share Posted October 18, 2010 The way I read your question I agree with Pikachu2000 it looks like you could just do individual groups rather than going down and making all those groups the same thing. Quote Link to comment Share on other sites More sharing options...
facarroll Posted October 18, 2010 Author Share Posted October 18, 2010 I will store a user supplied name for the field "group1". Obviously, the text input will be whatever the user decides, but elsewhere I need to be able to search the database for this record based on the data supplied by the user. I can do this if I have an accompanying field with one of the six preset names. I cannot search on the user supplied data because it could be anything, meaningful only to the user. Ask me further if this does not make sense. Quote Link to comment Share on other sites More sharing options...
facarroll Posted October 18, 2010 Author Share Posted October 18, 2010 I'll try to explain further. When the user enters text into the form, it is meaningful only to that user. It is always a name, but could be "Bill", or "grade3", or "new students". There are six fields the user can use. I want to have a preset name that goes into the record, being group1 to group6. Then I can search the database for the preset field names and derive the user names accordingly. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 18, 2010 Share Posted October 18, 2010 It might make more sense if we knew the big picture, such as what other information is being stored, and the database structure. Right now it seems that if you were to just give the field the data is stored in a descriptive name, it would be unnecessary to have additional fields. Quote Link to comment Share on other sites More sharing options...
facarroll Posted October 18, 2010 Author Share Posted October 18, 2010 Working on it. I'll get back to you. You can see the site at www.safetytestingonline.com. 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.