john_6767 Posted October 3, 2006 Share Posted October 3, 2006 i'm trying to make an insert page that adds in a client and also adds into the client_areas table the areas that the client is interested in.. (these areas are displayed as checkboxes from the area table..) so i have to insert the client and then insert multple times into the client_areas joining table. I have use a script in asp before and it works exactly right but now i am using php i cannot work out how to do it. (script is in asp and called 'Insert/Update Multiple Tables', i found it here http://charon.co.uk/files.aspx?categoryid=15&filecategoryid=10). Anyone know of any tutorials or code to do this in php? Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 3, 2006 Share Posted October 3, 2006 one of the easiest ways i've found to do this is simply to name all the associated checkboxes as an array and to loop through them all on the processing page:[code]<?phpif (isset($_POST['submit'])) { // check to see at least one of your "myCheck" boxes was submitted if (isset($_POST['myCheck']) && count($_POST['myCheck']) > 0) { foreach ($_POST['myCheck'] as $val) { // now, here is where you would insert your value into your database } }}echo "<form name=\"test\" action=\"\" method=\"post\">\n";for ($i = 1; $i <= 10; $i++) echo "<input type=\"checkbox\" name=\"myCheck[]\" value=\"$i\" /> $i<br />\n";echo "<input type=\"input\" name=\"submit\" value=\"Submit\" />\n";echo "</form>\n";?>[/code]hope this helps Quote Link to comment Share on other sites More sharing options...
john_6767 Posted October 3, 2006 Author Share Posted October 3, 2006 this does help a bit with concepts but i don't know enough php to get a working version.. do you have a simple working example page i could look at? 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.