I'm trying to delete image from database in php oops. I created this class. It delete data from data base but not unlike function is not working some one. Plz help me.
<!-- session start -->
<?php
if (($session->logged_in) && ($session->isAdmin())) {
}
else{
header("Location: index.php");
}
?>
<!-- session end here -->
<?php
$obj=new Crud("localhost","root","","3g");
class Crud{
public $mysqli;
public $data;
public function __construct($host,$username,$password,$db_name){
$this->mysqli = new mysqli($host, $username, $password, $db_name);
if(mysqli_connect_errno()) {
echo "Error: Could not connect to database.";
exit;
}
/*else{
echo"Your Database successfully connected";
}*/
}
public function __destruct(){
$this->mysqli->close();
}
public function read(){
$query="SELECT * FROM fashion";
$result= $this->mysqli->query($query);
$num_result=$result->num_rows;
if($num_result>0){
while($rows=$result->fetch_assoc()){
$this->data[]=$rows;
//print_r($rows);
}
return $this->data;
}
}
public function delete($id){
$sql=mysql_query("select * from fashion where where id='$id'");
$row=mysql_fetch_array($sql);
unlink("fashion/$row[thumbnail_image]");
$query="DELETE FROM fashion WHERE id='$id'";
$result= $this->mysqli->query($query) or die(mysqli_connect_errno()."Data cannot inserted");
if($result){
header('location:fashion.php');
}
}
}
?>
I have tried soo many codes and try some different ways but the problem is still not solved.