I'm having troubling updating status row in my mysql table using PDO procedure. The status row is defined as 0 in the table, so i want it to change to 1 whenever i hit the confirm button but it couldn't and i have been trying to fix it all night but i could not.
Here is my db connection
<?php
class Database
{
private $host = "localhost";
private $db_name = "jerrydb";
private $username = "root";
private $password = "";
public $conn;
public function dbConnection()
{
$this->conn = null;
try
{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $exception)
{
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
}
?>
here is my script, i want the confirm to disappear whenever i clicked on it and at the same time change status row to 1.
<?php
if (isset($_GET['entity']) && isset ($_GET['action']) && isset($_GET['user_id'])){
$entity = mysqli_real_escape_string($db, $_GET['entity']);
$action = mysqli_real_escape_string($db, $_GET['action']);
$user_id = mysqli_real_escape_string($db, $_GET['user_id']);
$query = "UPDATE jerrydb set status = '1' WHERE user_id='$user_id'";
$db->query($query);
}
$query = "SELECT * FROM jerrydb WHERE status='0' ORDER BY user_id DESC";
$jerrydb = $db->query($query);
?>
<?php if($row = $jerrydb->fetch_assoc()) { ?>
<tr>
<td><a href="index.php?entity=go&action=approve&id=<?php echo $row['id'];?>" class="btn btn-success">Confirm</a> </td>
</tr>
<?php } ?>