I have shop site and want to be able delete what I add but can't seem to get it to work.
All relevant code is below:
Home page:
<?php
//external pages area
include_once('config/database.php');
include_once('object/chair.php');
//grabs info from the various pages.sql files
$database = new Database();
$conn = $database->getConnection();
$chair = new Chair($conn);
//connection made with sql file
$stmt = $chair->readAll();
//reading all the data in the sql file
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
?>
<div class="ProductActionAdd" style="display:;">
<a href="chair-details.php?detailsid=<?php echo $row['ID'];?>" class="btn">Buy me!</a>
</div>
Details page:
<?php
include_once('config/database.php');
include_once('object/chair.php');
$database = new Database();
$conn = $database->getConnection();
$chair = new Chair($conn);
$chair->id = $_GET['detailsid'];
$stmt = $chair->readDetails();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
?>
<a href='delete-chair.php?detailsid=<?php echo $row['ID'];?>' class="deleteit">deleate</a>
Delete page:
<?php
include_once('config/database.php');
include_once('object/chair.php');
$database = new Database();
$conn = $database->getConnection();
$chair = new Chair($conn);
$chair->id = $_GET['detailsid'];
$stmt = $chair->readAll();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
?>
<div class="center_items">
<div class="all-items">
<?php
$sql="DELETE FROM office_chairs WHERE id ='{$chair->id}'";
}
?>
It states that detailsID is undefined and that Object of class chairs can't be converted into a string.