Translate

Thursday 18 September 2014

Status Update for Delete Option using PHP

Explaination:

            In this coding instead of deleting we have to update the status.
            If the status is 0 means it will display the results and if the status in 
            1 means it has been updated and is not displayed it has hide.In future suppose we want the 
            data means this is the good one to use like this also.
            I hope this tutorial is very helpful for the Developers and the PHP Beginners.

Form:

<form method='post' action=''>
 <input type='hidden' name='reference_number' value='$value3[reference_number]'>
 <input type='submit' name='delete' value='Delete' >
 </form>



Upadte Coding in PHP:




<?php
if(isset($_POST['delete']))
{
//print_r($_POST);exit;
$reference_number=$_POST['reference_number'];
$update=mysql_query("update tbl_name set delete_status='1' where reference_number='$reference_number'");
}
$query3 = "SELECT * FROM tbl_name where delete_status='0' ORDER BY inventory_id desc";
$result3 = mysql_query($query3);
$size   = mysql_num_rows($result3);
while($details = mysql_fetch_array($result3)) {
$row3[] = $details;
}

?>

Fetching with DB:

<?php
if($row3) {
foreach($row3 as $key3 => $value3) {
$slno = $key3 + 1;
$invi = $value3[inventory_id]+123456;
echo "<tr class='table_tr2'>";

echo "<td align='center'>
<form method='post' action=''>
<input type='hidden' name='reference_number' value='$value3[reference_number]'>
<input type='submit' name='delete' value='Delete' class=''>
</form>
</td>";
echo "</tr>";
}
} else {
echo "Not Available";
}

?>     

No comments:

Post a Comment