I have this PHP code/form:
<form method="post" action="tickets_report2.php">
<table width="800" border="0" cellspacing="5" cellpadding="5">
<tr>
<td><strong>Select</strong></td>
<td><strong>Company</strong></td>
</tr>
<?php
$sql="SELECT * from customer ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
$counter=0;
while($result=mysql_fetch_array($rs)) {
$counter++;
echo '<tr>
<td><input type="checkbox" value="'.$result["sequence"].'" name="checkbox'.$counter.'" /></td>
<td>'.$result["company"].'</td>
</tr>';
}
echo '<input type="hidden" name="counter" value="'.$counter.'" />';
?>
</table>
<input type="submit" name="submit" value="Next" />
</form>
and on the form action page:
<table width="800" border="0" cellspacing="5" cellpadding="5">
<tr>
<td><strong>Company</strong></td>
</tr>
<?php
for($i=1; $i<=$_POST["counter"]; $i++) {
if($_POST["checkbox$i"]) {
$sql="SELECT * from customer where sequence = '".$i."' ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
$result=mysql_fetch_array($rs);
echo '<tr>
<td>'.$result["company"].'</td>
</tr>';
}
}
?>
</table>
lets say i check the checkbox on the form for the row in the database with sequence of 278, the SQL Query should say SELECT * from customer where sequence = '278'
but its showing SELECT * from customer where sequence = '1'
i think its using the counter rather than the customer sequence
what do i need to change to get this working correctly so it selected the correct customer(s)