[thelist] Updating multiple row forms

Santilal Parbhu santilal at scorpioneng.co.nz
Mon Apr 24 03:55:09 CDT 2006


Hi,

I am trying to write a PHP script to update multiple rows of a form.  Say I
am wanting to edit the time and date of a sports draw.  I am using a form to
print out all of the rows of data (say all of the matches), then I want to
edit all of the form entries together, updating them with a single submit.

I am using the following script fragment:

echo  '<form method="post" action="editdraw_multi_rows.php"><tr>';
echo    '<input type="hidden" name="match_id['.$draw_row_id.']"
value="'.$draw_row_id.'">';
echo    '<input name="date['.$draw_row_id.']" type="text"
id="date['.$draw_row_id.']" size="5" value="'.$row[2].'">';
echo    '</div></td>';
echo    '<td><div align="center">';
echo      '<input name="time['.$draw_row_id.']" type="text"
id="time['.$draw_row_id.']" size="5" value="'.$row[3].'">';

This form is populated from a mysql fetch array query, so that each time a
new row of data is used.  What I think I am trying to achieve is that each
time the loop runs, a new name is given to the form input.  e.g. date1,
time1; date2, time2; date3, time3 etc.  I found a script that was doing
something similar on the net, but I don't understand the '<input
name="time['.$draw_row_id.']" construct.  What are the two periods either
side of the $draw_row_id?  Also, the braces suggest that I am accessing
elements  of the array rather than modifying the element name.

Also, when I read back these variabls from the POST method I am using the
following:
$time=$HTTP_POST_VARS['time'][$id]; Again, I am hoping this will change on
each cycle of the loop e.g. $time=$HTTP_POST_VAR['time1']; on the first
pass, $date=$HTTP_POST_VARS['time2']; on the second pass etc.  Again, I
can't find the $time=$HTTP_POST_VARS['time'][$id]; construct defined
anywhere.

Hoping someone can help, and that I have defined my problem clearly enough.


Santilal Parbhu
Scorpion Engineering Limited
PO Box 171
Alexandra

Phone 03 448 5421
Fax 03 448 5421
Mobile 021 265 5991
Web www.scorpioneng.co.nz





More information about the thelist mailing list