Brent Baisley wrote: > It's actually a very simple solution, and you should do it all in a > single INSERT. Putting INSERTs in a loop will kill your performance > when you try to scale. > > $sql4 = 'INSERT INTO test (example) VALUES (' . implode('),(', > $_POST["categoriesIN"]) . ')'; > $result4 = mysql_query($sql4, $db); Please explain this... I do not understand how the implode is being used here. As I understand it, the above code would aoutput or rather INSERT all the choicees into one field as choice numbers separated by a , (like 1, 3, 4) or what? I suppose I could use that but I'm not sure if this is the way to go. I understand the performance problem and would like to keep it simple. > > That example does not sanitize the data before inserting. I know, but I am just testing locally for now. Will sanitize later. > > Brent Here is my test page: Questions below that. <html> <head> <title>test form</title> </head> <body> </body> <? session_start(); // Include sessions_start() in everything include ("db1.php"); $thisInterface = "addNewBooks"; if (!isset($_SESSION["addNewBooks"])) { $categoriesIN = ""; // Save the input variables in session variables $_SESSION["categoriesIN"] = $categoriesIN; // Remember that addNewBooks.php has been entered once $_SESSION["addNewBooks"] = 1; } else {$categoriesIN = $_SESSION["categoriesIN"]; } if (isset($_REQUEST["AddNewBooksRequest"])) $categoriesIN = $_POST["categoriesIN"]; ?> <form method="post" action="multiple_category_insert.php"> <select name="$categoriesIN[]" multiple size="5"> <option > Choose categories... </option> <option value="1">History</option> <option value="2">Temples</option> <option value="3"> Cleopatra</option> <option value="4"> Mummies</option> </select> <input type="submit" name="submit" value="submit"> </form> <? $sql4 = "INSERT INTO test (example) VALUES (' . implode('),(', $_POST["$categoriesIN"]) . ')"; $result4 = mysql_query($sql4, $db); ?> <table align="center" border="0" cellpadding="3" width="90%"> <tr> <td align="center"><b> <input class=textbox type="submit" name="AddNewBooksRequest" value="Insert New Books"> </b> </td> </tr> </table> </html> ========== Question 1. What should be entered into the name=" something " to make it work? Question 2. How should the $sql4 = "INSERT...... be completed? I know the code above is not working but I can't figure out what's wrong. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php