I want to have this table and user will be able t delete row of data if they wish to with the checkbox. But the errors i don't know how to solve:
Notice: Undefined index: itemcode in /home/lh026/public_html/pro1/ostock.php on line 153
Notice: Undefined index: saiz in /home/lh026/public_html/pro1/ostock.php on line 154
Notice: Undefined index: quantity in /home/lh026/public_html/pro1/ostock.php on line 155
1 Records deleted Successfully.
The data is not deleted in database but message show 1 Records deleted Successfully...Please help.
<form name="form1" method="POST" action="">
<div id="content2" class="float_r">
<h1> </h1>
<h4><a href="addstock.php"><img src= "img/add.png" /><strong> Add Items</strong></a></h4>
<p><strong><font color="red">
<?php
if($nume==0)
{ echo "You currently have no item to show"; }
else if(isset($_GET['msg']))
{
$msg = $_GET['msg'];
if($msg!='')
{
echo '<table border="1">
<tr>
<td><font color="red">'.$msg.'</font></td>
</tr>
</table>';
}
}
?>
</font></strong></p>
<table width="747" cellspacing="0" cellpadding="5">
<tr bgcolor="#ddd">
<th width="61"> </th>
<th width="98" align="left">Date </th>
<th width="87" align="left">Item Code </th>
<th width="76" align="left">Quantity</th>
<th width="39" align="left">Size </th>
<th width="270" align="left">Remark</th>
<th width="44" align="left">ID </th>
</tr>
<?php
$start=(isset($_GET['start'])) ? (int)$_GET['start']:0;
if(strlen($start) > 0 and !is_numeric($start))
{
echo "Data Error";
exit;
}
$eu = ($start - 0);
$limit = 5;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$date = date("Y-m-d",time() + (8 * 3600));
$result = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,
pstaff.staff_id
FROM orderdb ,pstaff
WHERE orderdb.staff_id =pstaff.staff_id
AND orderdb.staff_id='$id'
AND orderdb.odate='$date'");
?>
<?php
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row['odate'].$row['itemcode'].$row['saiz']; ?>"></td>
<td><?php echo $row['odate'];?></td>
<td><?php echo $row['itemcode'];?></td>
<td><?php echo $row['quantity'];?></td>
<td><?php echo $row['saiz'];?></td>
<td><?php echo $row['remark'];?></td>
<td><?php echo $row['staff_id'];?></td>
<?php
echo"<td><a href='update.php?id=".$row['odate']."'>Update</a></td>";
?>
<?php
}
?>
<tr><td><input type="submit" name="delete" value="Delete" id="delete"></td></tr></tr></table>
<?php
// Check if delete button active, start this
$count = mysql_num_rows($result);
echo "$count";
if(isset($_POST['delete']))
{
$date = date("Y-m-d",time() + (8 * 3600));
$dcode = $_GET["itemcode"];
$dsaiz = $_GET['saiz'];
$dquantity = $_GET['quantity'];
$delete_id = $_POST['checkbox'];
$id = count($delete_id );
if (count($id) > 0)
{
foreach ($delete_id as $id_d)
{
$sql = "DELETE FROM orderdb WHERE itemcode='$dcode' AND odate='$date' AND saiz='$dsaiz'";
$delete = mysql_query($sql);
$sql2 = "UPDATE pStockSize SET quantity=('$dquantity'+quantity) WHERE itemcode='$dcode' AND size='$dsaiz'";
$update = mysql_query($sql2);
}
}
if($delete)
{
echo $id." Records deleted Successfully.";
}
}
?>
</div>
</form>