i Have an url stands as : http://website.com/update.php?id={NUMBER}
How would I make PDO grabs the results from that specific id?
Here is my attempt for update.php page :
try {
$dbh = new PDO("mysql:host=$hostname;dbname=vector",$username,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id = '. $id .'";
foreach ($dbh->query($sql) as $row)
{
?>
<?php echo $row['username']; ?>
<?php
}
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>