I have a table with a delete action, but when I go to click it and get prompted to delete the item. It gives me an error. This is connecting to Access database.
Here is the code for the table
<table class="table-bordered ">
<tr>
<th width="91"> <div align="center">ID </div></th>
<th width="91"> <div align="center">VendorID </div></th>
<th width="98"> <div align="center">ItemNumber </div></th>
<th width="98"> <div align="center">ItemDescription </div></th>
<th width="98"> <div align="center">UnitDisplay </div></th>
<th width="98"> <div align="center">Cost </div></th>
<th>Action</th>
</tr>
<?php
for($i=$Page_Start;$i<=$Page_End;$i++)
{
$objResult = odbc_fetch_array($objExec,$i);
?>
<tr>
<?php $id = $objResult['ItemID'];?>
<?php echo "<td> <a href='update.php?ItemID=$id'>$id</a></td>"?>
<td><div align="center"><?php echo $objResult["VendorID"];?></div></td>
<td><?php echo $objResult["ItemNumber"];?></td>
<td><?php echo $objResult["ItemDescription"];?></td>
<td><?php echo $objResult["UnitDisplay"];?></td>
<td><?php echo $objResult["Cost"];?></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='DeleteRecord.php?ItemID=<?php echo $objResult["ItemID"];?>';}">Delete</a></td>
</tr>
<?php
}
?>
</table>
Here is the code for the deleteRecord.php
<?php
$objConnect = odbc_connect("SupplyRequest","","") or die("Error Connect to Database");
$strSQL = "DELETE FROM tbl_Items ";
$strSQL .="WHERE ItemID = '".$_GET["ItemID"]."' ";
$objExec = odbc_exec($objConnect, $strSQL);
if($objExec)
{
echo "Record Deleted.";
}
else
{
echo "Error Delete [".$strSQL."]";
}
odbc_close($objConnect);
?>