close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Insert Multiple Records

Thread began 2/06/2019 9:56 am by LWat85283715 | Last modified 2/06/2019 12:21 pm by LWat85283715 | 1790 views | 7 replies

LWat85283715

Insert Multiple Records

I am trying to insert multiple records from a form. I can get it to insert the records but, it is not looping through the number of designated data elements selected. What I need for it to happen is for every district selected, it will add a record for every data element selected. Attached is a screenshot of the page.


Here is the insert code:

<?php
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
$element = $_POST['data_elementID'];
foreach($element as $name=>$value) {
$InsertQuery = new WA_MySQLi_Query($sdpc_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "district_data_elements";
$InsertQuery->bindColumn("districtID", "i", ((isset($_POST["districtID"]))?$_POST["districtID"]:"") , "WA_NULL");
$InsertQuery->bindColumn("softwareID", "i", "".((isset($_POST["softwareID"]))?implode(",",$_POST["softwareID"]):"") ."", "WA_NULL");
$InsertQuery->bindColumn("data_elementID", "i", ((isset($_POST["data_elementID"]))?$_POST["data_elementID"]:"") , "WA_NULL");
$InsertQuery->saveInSession("");
$InsertQuery->execute(); }
$InsertGoTo = "manage_agreements_state.php?state=".$_GET['state'] ."&districtID=".$_GET['districtID'] ."";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

Here is the form code:

<form method="post" enctype="multipart/form-data">


<div class="row">
<div class="col-xs-5">
<select name="from[]" id="search" class="form-control" size="15" multiple="multiple">
<?php
while(!$category->atEnd()) { //dyn select
?>
<option value="<?php echo($category->getColumnVal("data_elementID")); ?>"><?php echo($category->getColumnVal("element_name")); ?></option>
<?php
$category->moveNext();
} //dyn select
$category->moveFirst();
?>
</select>
</div>
<div class="col-xs-2">
<button type="button" id="search_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>
<button type="button" id="search_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>
<button type="button" id="search_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>
<button type="button" id="search_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>
</div>
<div class="col-xs-5">
<select name="data_elementID[]" id="search_to" class="form-control" size="15" multiple="multiple">
</select>
</div>
</div>
<p>&nbsp;</p>
<h4>Please select the district(s) that use this resource that you would like to assign these data elements to:</h4>
<div class="row">
<div class="col-xs-5">

<select name="from[]" id="search2" class="form-control" size="15" multiple="multiple">
<?php
while(!$districts_selected->atEnd()) { //dyn select
?>
<option value="<?php echo($districts_selected->getColumnVal("districtID")); ?>"><?php echo($districts_selected->getColumnVal("district_name")); ?></option>
<?php
$districts_selected->moveNext();
} //dyn select
$districts_selected->moveFirst();
?>
</select>

</div>
<div class="col-xs-2">
<button type="button" id="search2_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>
<button type="button" id="search2_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>
<button type="button" id="search2_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>
<button type="button" id="search2_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>
</div>
<div class="col-xs-5">
<select name="districtID[]" id="search2_to" class="form-control" size="15" multiple="multiple">
</select>
</div>
</div>

<input type="hidden" name="softwareID[]" id="softwareID" value="<?php echo $_GET['softwareID']; ?>" />

<br><br>
<input type="image" src="images/save.png" name="submit" id="submit" alt="Save" />
</form>

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

Content

rating

Layout

rating

Ease of use

rating

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...