iMei No# |
Model |
Edit |
Delete |
[insert_php]
$conn = mysqli_connect(“theftfound.com”,”theftfou”,”arR37e?x#eNp”,”theftfou_blacklist”) or die (“Error in connecting Database!..”);
//First Function to load Table View For the First time
if(isset($_POST[‘locate’])){
//$nic = $_POST[‘nic’];
$nic = isset($_POST[“nic”]) ? $_POST[“nic”] : ”;
if(strlen($nic)!=0){
//$link = mysql_connect(“theftfound.com”,”theftfou”,”arR37e?x#eNp”);
//mysql_select_db(“theftfou_blacklist”,$link);
//$run = mysql_connect(“SELECT * FROM `lost` WHERE nic = ‘$nic'”)
$stmt = $conn->prepare(“SELECT * FROM `lost` WHERE nic = ?”);
$stmt->bind_param(“s”, $nic);
$stmt->execute();
$result = $stmt->get_result();
//while($row=mysql_fetch_array($run)){
$num = mysqli_num_rows($result);
$rows = array();
//while ($r = mysqli_fetch_assoc($result)){
while($rows = $result->fetch_assoc()) {
//$id = $row[id];
// $imeit = $row[imei];
// $mname = $row[mname];
//$pamount = $row[pamount];
//$pname = $row[pname];
//$address = $row[address];
//$contact = $row[cnumber];
//$nict = $row[nic];
//
$rows[pamount] |
$rows[pname] |
$rows[address] |
$rows[cnumber] |
echo “
$rows[imei] |
$rows[mname] |
Edit |
Delete |
“;
//’/?delete_id={$rows[‘id’]}\’
}
}
else
{
echo ““;
echo ‘
‘.’Please enter a valid National ID Card Number and then Press Search Button‘;
}
}
// Second Function to Load Table View for the next times with Delete
//3rd Change
if(isset($_GET[‘delete’])&& !empty($_GET[‘delete’]) AND isset($_GET[‘nic’])&& !empty($_GET[‘nic’])){
$del= isset($_GET[“delete”]) ? $_GET[“delete”] : ”;
// $delete_id = (int) $_GET[‘delete_id’];
$nic_r= isset($_GET[“nic”]) ? $_GET[“nic”] : ”;
// $nic_r =(int) $_GET[‘nic_r’];
$sql = “DELETE FROM `lost` WHERE id = (‘$del’)”;
$result=$conn->query($sql);
if ($result){
echo ““;
echo ‘‘.’‘.’Deleted Successfully‘.’
‘.’‘.’‘;
$stmt = $conn->prepare(“SELECT * FROM `lost` WHERE nic = ?”);
$stmt->bind_param(“s”, $nic_r);
$stmt->execute();
$result = $stmt->get_result();
$num = mysqli_num_rows($result);
//2nd Change
$rows = array();
while($rows= $result->fetch_assoc()) {
//1 Change
echo “
$rows[imei] |
$rows[mname] |
Edit |
Delete |
“;
}
}
else
{
echo “failed!!!!”.mysqli_error($conn);
}
}
//Third Function for Table to retrieve from edit page
if(isset($_GET[‘nic_u’])){
$nic= isset($_GET[“nic_u”]) ? $_GET[“nic_u”] : ”;
echo ‘‘.’‘.’Updated Successfully‘.’
‘.’‘.’‘;
$stmt = $conn->prepare(“SELECT * FROM `lost` WHERE nic = ?”);
$stmt->bind_param(“s”, $nic);
$stmt->execute();
$result = $stmt->get_result();
$num = mysqli_num_rows($result);
//2nd Change
$rows = array();
while($rows= $result->fetch_assoc()) {
echo “
$rows[imei] |
$rows[mname] |
Edit |
Delete |
“;
}
}
[/insert_php]