Reply to Updating multiple records from one form

Your name:

Reply:


Posted by Gand on 11/07/05 07:31

Hiya
I posted this on another forum so it might save time if i paste what
we covered so far
I am just stuck on the last section as i seem to be passing the same
ID each time instead of the unique one.


Any help would be awesome...

I have a form that displays 5 records in a recordset. Each record has
an image and a drop down menu and the unique ID. The drop down menu is
the state and can be on or off.

By default all states are set to on but what i am trying to do is have
it so the users can turn off what they want using the drop down menus
and press one submit button to update the state to what they have
chosen from the drop down menus.

I was able to use an array for an insert statement using checkboxes
from a form, but i am struggling with this one.

I am using the code I had from the insert array tweaked a little. This
will update one of the records from the recordset but not the
remaining 4.

The form field names are:
selectID (this is the unique ID)
box1[] (this is the state drop down menu, can be on or off)
pic (this is just an image)

PHP:
PHP<?
$box=$_POST['box1'];
$selectID=$_POST['selectID'];
$box_count=5;

foreach ($box as $dear) {
$selectID=$_POST['selectID'];
mysql_select_db($database_gdn, $gdn);
$query_Recordset1 = ("UPDATE pics_selected SET state = '$dear'
WHERE selectID = '$selectID'");
$Recordset1 = mysql_query($query_Recordset1, $gdn) or
die(mysql_error());
header("Location: games_accept.php");
}

?>


The form field names are:
selectID (this is the unique ID)
box1[] (this is the state drop down menu, can be on or off)
pic (this is just an image)

so
$box=$_POST['box1'];
is an array with the on or off... does it look something like
$box(
[0] => 1,
[1] => 0,
[2] => 0,
[3] => 1,
[4] => 1,
)

but what does
$selectID=$_POST['selectID'];
look like if you print_r($selectID)

because it looks like your passing only one id, thats why it'll update
(guessing) the last one in the form.

You are correct. If i add print_r($selectID); into the loop then it
prints out the final ID five times.

What would i need to change in order to pass each ID?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация