close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Looping insert of multiple rows

Thread began 8/30/2016 2:54 pm by LionsMane | Last modified 8/30/2016 5:21 pm by Ray Borduin | 2854 views | 8 replies |

LionsMane

Looping insert of multiple rows

I have a form with jQuery function, allowing the user to add as many rows to the form/table as they'd like. Each added row has identical fields, obviously. I'd like to use this mySQLi INSERT behavior to loop through each of the user-added rows, and store each row. Any examples out there of how I can do this?

Sign in to reply to this post

Ray BorduinWebAssist

I don't have any examples. It is something I could help with in a premier support ticket.

I think if you name your fields with brackets like: name="field1[]" then it will submit them as an array. Then you can manually wrap your insert statement with a loop around that array to do the multiple inserts.

Sign in to reply to this post
Did this help? Tips are appreciated...

LionsMane

Looping

Thanks Ray. Yeah, the fields in question already have IDs with the [] brackets because we're looping through the fields to assemble an HTML email that gets sent to the client. That part works great. I effectively now need to do the same thing. It's the context of how to write that in the mySQLi INSERT code that I'm unsure of. If you can throw together a few lines of example on how to setup a look with your behavior code, I can try to hack it together to do what I need. I *feel* like it'd be a real quick answer, and hard to justify the $99 for this one! Maybe I'm wrong though...

Sign in to reply to this post

Ray BorduinWebAssist

Just wrap a for loop around your insert statement like:

<?php
for ($x=0; $x<sizeof($_POST['loopedfield']); $x++) {
?>
<?php
// mysqli insert here
?>
<?php
}
?>

Then in your insert bindings use something like:
<?php echo($_POST['loopedfield'][$x]); ?>

Sign in to reply to this post
Did this help? Tips are appreciated...

LionsMane

insert bindings?

Hey thanks Ray. Umm... Insert Bindings? I don't quite follow which chunk that is.. Sorry to sound dense.

Sign in to reply to this post

Ray BorduinWebAssist

I mean the bindings tab in the insert server behavior.

Sign in to reply to this post
Did this help? Tips are appreciated...

LionsMane

OK

I think I'm following now. Will try.

Sign in to reply to this post

Ray BorduinWebAssist

You would bind it to whatever column you want it to be inserted into on the bindings tab.

Sign in to reply to this post
Did this help? Tips are appreciated...

LionsMane

Got it

This is working.. thanks again

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