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

multiple Insert based on form data?

Thread began 4/09/2012 9:58 am by clive.henderson222953 | Last modified 5/03/2012 8:12 am by clive.henderson222953 | 772 views | 4 replies |

clive.henderson222953

multiple Insert based on form data?

Hello

I have a form which I use to insert a row into a table.

One data field within the form is a number (x)

I’d like to be able to write multiple(x) rows to my database based on the value (x) when the submit button is clicked

Is there a way to so this?
Or if you can give me any pointers, it would be really appreciated

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

this can be done but will require hand coding to accomplish and is not supported.

you would need to capture the value from the number field and store it in a variable, then create a loop around the insert record behavior to perform the insert that many times:

php:
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
    
$count $_POST['numberField'];
    for(
$i 0$i $count$i++) {
?>
<insert record code>
<?php
    
}
}
?>



if you need help accomplishing this, I would suggest signing up for a premiere ticket appointment.

Sign in to reply to this post

dvan_zelst

Is it not easier the create an array with the x elements and values you need.
Then explode this array in the SQL syntax for the values? This way you create one SQL insert statement that will insert x values at once. This will avoid sql server load. Imagine you need to insert 10000 recors withing a loop will cause a much havier load on the server while having one insert statement with 10000 values will be much faster.

Just my idea.

Sign in to reply to this post

Jason ByrnesWebAssist

that could work too, but assumes that the data inserted to the database will be static values. The OP doesn't comment on what values will be stored in the database, only that he wants to create a new row, I would think the reason for creating the new row would be store some sort of dynamic data from the form. Impossible to tell which method would be best with the limited information.

Sign in to reply to this post

clive.henderson222953

Thanks, much appreciated.
Jason is correct though as I do wish to include dynamic data
I think that the max number of occurrences will be les than 50 normally so server load hopefully won't be an issue.
Thanks again for taking the time to help.
Regards
Clive

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