Trying to pass an array via a dynamically generated form. The array would be iterated on the next page load to construct a mysql UPDATE query.
Here is the code I am using:
//USING GET METHOD TO DEBUG
<form method="get" name="update" action="<?php echo $reload;?>">
<?
for ($i=0; $i < $numfields; $i++)
// DISPLAY HEADER OF TABLE WITH COL NAMES
{ echo '<th>'.mysql_field_name($results, $i).'</th>'; }
echo "</tr><tr>\n";
$edit = mysql_fetch_row($results);
foreach ($edit as $key => $field){
// INPUT FIELDS GENERATED HERE
//THIS IN THE PROBLEM AREA
echo '<td><input type="text" name="data[' . $key . ']" value="' . htmlspecialchars($field) . '"</td>';
}
?>
<input type="submit" name="submit" value="Update">
<input type="hidden" name="table" value="<?php echo "$table";?>">
</form>
The "$_GET" is returned this way:
data[0]=3&data[1]=Yes&data[2]=1
Rather than an array, it is passed as individual arrays. I have tried all sorts of variants:
using name="data" ... returns: data=3&data=Yes&data=1.
using name="data[]" ... returns data[]=3&data[]=Yes&data[]=1.
How can I code it to return data[]=array or data=array so I can loop through it and construct the query??