So, I've been trying this multiple delete thing with a checkbox and I did look on the internet for some code snippets and up to now, I have this:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>Intrious Website</title>
<link rel="stylesheet" href="tablestyle.css" type="text/css" />
</head>  
<body>  
<?php include('includes/header.php'); ?>
<div id="main">
<h1>Hardware Delete<h1>

<?php 
include("base.php");
$query = mysql_query("SELECT * FROM hardware"); 


$count=mysql_num_rows($query);
?>

<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Please check which data to delete.</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Tag</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Specifications</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Purchase Date</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Warranty Expiry Date</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Vendor</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Invoice</strong></td>
</tr>

<?php
while($rows=mysql_fetch_array($query)){
?>


<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFFF"><? echo $rows['Hw_tag']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['Hw_name']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['Hw_specs']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['Hw_purchaseDate']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['Hw_warrantyExpire']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['vendor_ID']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['invoice_ID']; ?></td>
</tr>

<?php
}
?>

<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input type="button" value="Back" onClick="window.location = 'hardware_display.php'"></td>
</tr>

<?php

// Check if delete button active, start this 
if(isset($_POST['delete'])){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$query = mysql_query("DELETE FROM hardware WHERE id='$del_id'"); 

}
// if successful redirect to hardware_delete.php 
if($query){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=hardware_delete.php\">";
}
}
mysql_close();
?>

</table>
</form>
</td>
</tr>
</table> 

</body>
</html>

But the problem now is that when opened in the browser, the data from inside the databse isn't showing, and I don't know where i went wrong...

this is an example of the output visible in the browser...and my database is not empty..
err2

You have written select * .....
NOW * MEANS it will select columns itself and php array is case sensitive, look into your mysql table and see case of all column, it am sure it is no Hw_tag.

just use rows['case sensivite spelling as same in mysql ']

OR

manauly write column name in select query like select Hw_tag..... like that

all of the $rows are being echoed correctly... it has exactly the same column name as in my mySQL db..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.