How to refresh site if $_SESSION variable has changed
Posted
by
4ndro1d
on Stack Overflow
See other posts from Stack Overflow
or by 4ndro1d
Published on 2012-09-25T15:25:14Z
Indexed on
2012/09/25
15:37 UTC
Read the original article
Hit count: 197
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?
© Stack Overflow or respective owner