Multiple Record Update with one form

Dear All,
I wanted one form entry to update multiple records. I got this tutorial - it updates the form values in a Array and when the submit button is pressed, array updates the Records in the database.

// Check if button name “Submit” is active, then update record
if($Submit){

But I’m getting Undefined variable: Submit - error.

Please assist. Thanks.

Micky,

We would definitely need to see some code to be able to help you.

This is a long shot, but try replacing the following:[php]if($Submit){[/php]With[php]if($_REQUEST[‘Submit’]){[/php]
This is making a lot of assumptions at this point!

note This is assuming your form field name is equal to submit.

$submit should be = $_POST[‘submit’] and but you can skip all of this by doing the following.

[php]if(isset($_POST[‘submit’]))[/php]

Spring is correct in using isset().

The reason I recommended $_REQUEST is that we don’t know what the form method is and this should still work for either GET or POST.

Also, OP - note that the ‘Submit’ is case sensitive. Your original post used a capital S. This will have to exactly match the name of your submit button in your form.

spring and malasho thank you guys. you have helped me a lot. Now the control is getting into if session.
But have problem with updating the variables with array.

//upon selecting Submit Button if(isset($_POST['Submit'])) { for($i=0;$i<$ag_count;$i++){ $sql1="UPDATE pricelist SET costprice='$cprice[$i]', salesprice='$sprice[$i]' WHERE productcode ='$prodid[$i]'"; } } =================== But getting the following error…

Undefined variable: cprice
Undefined variable: sprice

Please assist. Thanks a lot.

Because you’re assigning the name field an empty array.
Why are you doing that?

Dear Spring the Array gets updated under input statement is it not??

Could you please correct the code… for me.

Thanks & Regards

Sponsor our Newsletter | Privacy Policy | Terms of Service