Hi,
I would be very grateful for anyone's help on this!
I have a php script that displays data from a SQL database in rows
E.G:
Name - Address - Age - Height - Weight - etc - [ ] (& a checkbox)
it successfully displays the data in rows, with a checkbox on the end.
I would like to be able to tick some checkboxes and then post only 'that' data to a new page
this is the code that i have on that page:
<form name="form" method="post" action="print.php">
$query = "SELECT * FROM database where field = '$value' ORDER BY id desc";
$result = mysql_query($query) or die("Query failed");
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
foreach ($line as $col_value) {
$x++;
if ($x == 1) { $id = $col_value; }
if ($x == 2) { $name = $col_value; }
if ($x == 3) { $age = $col_value; }
etc...
}
print "<table><tr>";
print "<td>$name</td>";
print "<td>$age</td>";
print "<td valign=top><input type=text name=id[] multiple value=$id>";
print "<input type=checkbox name=print[] multiple></td>";
print "</tr>\n";
$x = 0;
}
<input type="submit" value="Print" name="form">
</form>
I understand that it builds the data into an array, but im stuck, as to how you then display the array on the new page.
i did try this and it worked:
$POST['id'][0],$POST['print'][0]
$POST['id'][1],$POST['print'][1]
$POST['id'][2],$POST['print'][2]
$POST['id'][3],$POST['print'][3]
but what if i have a 100 rows and i select 100 rows, that would mean i would have to repeat the above code 100 times.
so really what i require is, if 30 rows are posted to the new page, then the ID of the 30 rows is grabbed and then put through a new loop, to display the new data.
any help very much appricated!!!
Thanks
Dave!