What I'm basically trying to do is retrieve an entire row from mysql database on checkbox selection. This code works fine for single selection. But on multiple selection it still retrieves a single row. How do I loop through it?
$sql = "Select * from $DB_TBLName WHERE Delivery_no = '{$_REQUEST['check'][0]}'" ;
echo $sql;
$result = @mysql_query($sql,$Connect) or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
if(isset($_POST['submit'])){
if(!empty($_POST['check'])) {
// Loop to store and display values of individual checked checkbox.
foreach($_POST['check'] as $selected) {
echo $selected ;
}
}
}
$sep = "\t";
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo mysql_field_name($result,$i) . "\t";
}
print("\n");
while($row = mysql_fetch_row($result)){
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++) {
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
$file_ending = "xls";
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
HTML CODE
<td class="border-right" align="center"><input type="checkbox" name="check[]" id="check[]" value= "<?php echo $row['Delivery_no']; ?>" /></td>
<td><?php echo $row['Delivery_no'];?></td>
<td><?php echo $row['Invoice_no'];?></td>
<td><?php echo $row['Bill_date'];?></td>
<td><?php echo $row['Bill_to_party'];?></td>
<td><?php echo $row['Quantity'];?></td>
<td><?php echo $row['Brand']; } ?></td>
</tr>
</table>
<br>
<input type= "submit" name="submit" id="submit" value="submit" class="btn btn-primary button-loading">