close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

form multi select list insert records

Thread began 6/06/2016 12:34 pm by Christopher West | Last modified 2/20/2019 10:52 am by Christopher West | 5079 views | 52 replies

Christopher WestCommunity Expert

Hi, Its almost working. it does insert the number of items I have selected. however, what its doing is inserted the same ID for all entries. After my test if I select all categories from the list, the ID which is being written to the table is the very first ID from those that I select.

For example is my database table consider of:

and if I select all the above in my multi-select list then it will create 5 records in the catalog table BUT all with ID 6 being stored.

Here is the code for the insert and the code for the html form:



for ($x=0$x<sizeof($_POST['selectedCats']); $x++) {
if (($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)) {
$InsertQuery = new WA_MySQLi_Query($ecartdb);
$InsertQuery->Action "insert";
$InsertQuery->Table "`catalog`";
$InsertQuery->bindColumn("CatalogCategoryID""i""".((isset($_POST["selectedCats"]))?implode(",",$_POST["selectedCats"]):"")  ."""WA_DEFAULT");
$InsertQuery->bindColumn("CatalogProductID""i""".$_SESSION['ProductID']  ."""WA_DEFAULT");
$InsertGoTo "product-manage.php";
  if (
function_exists("rel2abs")) $InsertGoTo $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";

<select name="selectedCats[]" style="width: 260px;" multiple="" class="chosen-select">

while(!$rsCategory->atEnd()) { //dyn select
if ("".($rsCategory->getColumnVal("CategoryParentID"))  ."" != "0") {  // WebAssist Show If
          <optgroup label="<?php echo($rsCategory->getColumnVal("CategoryID")); ?>">
// ("".($rsCategory->getColumnVal("CategoryParentID"))  ."" != "0")
              <option value="<?php echo($rsCategory->getColumnVal("CategoryID")); ?>"><?php echo($rsCategory->getColumnVal("CategoryName")); ?></option>
//dyn select

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...