How to refresh site if $_SESSION variable has changed
- by 4ndro1d
I'm writing in my $_SESSION variable from a database, when i clicked a link.
public function getProjectById($id){
$query="SELECT * FROM projects WHERE id=\"$id\"";
$result=mysql_query($query);
$num=mysql_numrows($result);
while ($row = mysql_fetch_object($result)) {
$_SESSION['projectid'] = $row->id;
$_SESSION['projecttitle'] = $row->title;
$_SESSION['projectinfo'] = $row->info;
$_SESSION['projecttext'] = $row->text;
$_SESSION['projectcategory'] = $row->category;
}
}
Now my variable is overwritten and I want to show these variables in my index.php like this:
<div id="textContent">
<?php
if(isset($_SESSION['projecttext']) && !empty($_SESSION['projecttext'])) {
echo $_SESSION['projecttext'];
}else {
echo 'No text';
}
?></div>
But of course, my page will not refresh automatically. How can I do that?