On my website I'm listing data from the database with the use of $query->fetch(PDO::FETCH_ASSOC);
. Everything is working fine except that after changing the database and redirecting with header()
the user must refresh the page again to actually see the changes. I don't know what is causing this and it seems odd that the content is there but only upon a second refresh. Any help would be great. Thanks.
This is the code that is listing data back to the user.
public function getCoilInfo ($coil_id) {
//Database Connection
$db = Database::getInstance();
//Query to select all information from `coils` tables based off $coil_id
$query = $db->getConnection()->prepare("SELECT * FROM `coils` WHERE coil_id = :coil_id");
$query->execute(array(
':coil_id' => $coil_id
));
//Return array with results
return $query->fetch(PDO::FETCH_ASSOC);
}
I then reference the following class like this:
$coil = new Coil();
$coilInfo = $coil->getCoilInfo($_GET['coil_id']);
echo $coilInfo['coil_name'];