bradkenyon Posted September 11, 2008 Share Posted September 11, 2008 I have a system that stores volunteers for a festival. I am about to redesign it, to make it more efficient. Currently I have it list their name, and I have an update/delete/view option next to it. I envision adding another column to that volunteer listing, a drop down w/ all the different venues that this volunteer can be assigned to. I want to know how you would be able to go down thru the list and select a venue for each volunteer in the list, then hit submit when I am done selecting each venue from each drop down list. So when I hit submit, it will automatically assign/update every volunteer w/ the appropriate venue (based on which one you selected from that drop down list. I'm not asking for the code, but asking for an explanation of how I would go about this, php and mysql wise. Thank you very much. Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted September 12, 2008 Share Posted September 12, 2008 its a simple php form handling. on the form_submit.php use the $_POST array $venue = $_POSt['venue'] UPDATE `volunteers` SET `venue` = '$venue' Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 12, 2008 Author Share Posted September 12, 2008 thank you I know how to do that, but isn't it a little more elaborate when updating multiple records at the click of a button Because you'll assign all the volunteers to a specific venue from a drop down list of possible choices, then it will go thru the list and plug the updates to each record Maybe a while loop to go down the list and plug each one into the db table? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 Basically. Can volunteers be at multiple venues? If they can, you may need some database restructuring. Post back and I'll explain, if so. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 12, 2008 Author Share Posted September 12, 2008 A volunteer can be assigned to only one venue Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 Oh, okay. That makes things much easier. I assume that you have a venues table and a volunteers table? And you link the volunteers table to the venues table through a pk/fk on the tables? Or are you storing them as like, text in the volunteers column? If you are, you'll want to do what I said at the beginning of the post. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 12, 2008 Author Share Posted September 12, 2008 sadly I only use one table. I know, a no no What do you mean fk/pk? I haven't coded anything for assigning a volunteer to a venue, that is what I'm planning to do Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 pk/fk = Primary Key/Foreign Key You're going to want to use two tables for this, by the way. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 12, 2008 Author Share Posted September 12, 2008 Would one table hold all the different types of venues with a unique id for each, which will be stored in the volunteers table under the venue column? Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted September 13, 2008 Share Posted September 13, 2008 exactly! Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 13, 2008 Author Share Posted September 13, 2008 now how would i go about updating multiple records by clicking submit. because i'll go thru and assign each volunteer to a venue by selecting one from a drop down list of venues, which will appear next to each volunteer's name. Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted September 14, 2008 Share Posted September 14, 2008 have the form like this: <option name="venues_uid1"><option value="venue number">Venue Name</option> Etc. </option> have the number as the user id of that user.... example: for user 4, its like this: <option name="venues_uid4"><option value="venue number">Venue Name</option> Etc. </option> and the backends like this: $users =mysql_query("SELECT * FROM user table")or die(mysql_error()); while($user = mysql_fetch_array($users)){ $id = $user['id']; //user id $decide = 'venues_uid'.$id; if(isset($_POST[$decide])){ update database; } } Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 17, 2008 Author Share Posted September 17, 2008 You have it as <option name="venues_uid4"> options dont use the name element, shouldn't it be: <select name="venues_uid4"> so the # 4 stands for the user's id? 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.