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

rating

Insert Multiple Records

Thread began 2/06/2019 12:56 pm by LWat85283715 | Last modified 2/06/2019 3:21 pm by Ray Borduin | 19 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>

Sign in to reply to this post

Ray BorduinWebAssist

Please attach the actual page instead of copy and pasting the contents in the future so that I can open the page in Dreamweaver to analyze it.

In your bindings you chose the CSV version of the binding instead of the Array version. You need to use the Array version to initiate the multiple update.

If you can provide a URL and FTP access then I could fully debug and try to help figure out if any other updates are necessary.

Sign in to reply to this post

LWat85283715

Sure. Attached is the actual file. Thanks for your help.

Attached Files
add_data_elements_multiple_state.php
Sign in to reply to this post

Ray BorduinWebAssist

If you can provide a URL and FTP access then I could fully debug and try to help figure out if any other updates are necessary.

Sign in to reply to this post

LWat85283715

It is a login restricted page. My company doesn't allow others to FTP but, I have TeamViewer if needed.

Sign in to reply to this post

Ray BorduinWebAssist

Try updating:

php:
$InsertQuery->bindColumn("softwareID", "i", "".((isset($_POST["softwareID"]))?implode(",",$_POST["softwareID"]):"")  ."", "WA_NULL");



to:

php:
$InsertQuery->bindColumn("softwareID", "i", "".((isset($_POST["softwareID"]))?$_POST["softwareID"]:"")  ."", "WA_NULL");
Sign in to reply to this post

LWat85283715

Sorry but, that didn't work. It added only 2 rows and there should of been 4.

Sign in to reply to this post

Ray BorduinWebAssist

I'm not sure what the issue might be. I don't offer free screen sharing support to help build applications unless a bug is identified in our tools.

I could set up a premier support ticket to look into this with you over the phone with a screen sharing session, but if there isn't an issue with the extension I'd have to charge you for it.

If you are comfortable with this, then give me a call or post a phone number in the private area where I can call you and we can set that up.

Sign in to reply to this post

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