Saturday, 15 March 2014

Delete Data and Grid View using PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Crime Reporting</title>
</head>

<body>
<?php
include_once("../Connection.php");
$c = new Connectionclass();
$c->connect();
if(isset($_REQUEST["area_id"]) && isset($_REQUEST["Status"]))
{
    if($_REQUEST["Status"] == "true")
    {
        $query="delete from area_master where area_id=".$_REQUEST["area_id"];
        $c->in_up_de($query);
        echo"<script>alert('Data Deleted');document.location='areadetail.php';</script>";
    }
    else
    {
        echo"<script>document.location='areadetail.php';</script>";
    }
}
else if(isset($_REQUEST["area_id"]))
{   
    echo"<script>
    var status = confirm('Are You Sure,You want to delete?');
    document.location='areagrid.php?area_id=".$_REQUEST["area_id"]."&Status='+status;
    </script>";
}

$query="select a.area_id,a.area_name,c.city_name from area_master as a inner join city_master as c on a.city_id=c.city_id";
$c->calldata($query);

echo"<table border='1'>";
echo"<tr>";
echo"<th>Area Id</th>";
echo"<th>Area Name</th>";
echo"<th>City Name</th>";
echo"<th>Delete</th>";
echo"<th>Update</th>";
echo"</tr>";

while($row=mysql_fetch_array($c->res))
{
    echo"<tr>";
    echo"<td>".$row[0]."</td>";
    echo"<td>".$row[1]."</td>";
    echo"<td>".$row[2]."</td>";
    echo"<td><a href='areagrid.php?area_id=".$row[0]."'><img src='images/delete_icon.png' width='50px'></a></td>";
    echo"<td><a href='areaupdate.php?area_id=".$row[0]."'><img src='images/update.png' width='70px'></a></td>";
    echo"</tr>";
}
echo"</table>";
?>

</body>
</html>

0 comments:

Post a Comment

Followers