$i = 1;
while($post = mysql_fetch_array($Articles)){
if(!isset($_SESSION['Art_Ses'][$i]) || $refresh_content == 1){
$_SESSION['Article_ID'][$i] = $post['Article_ID'];
$_SESSION['Article_Title'][$i] = $post['Article_Title'];
$_SESSION['Article_Topic'][$i] = "<b><a href=\"index.php?find=News&file=View_Articles&show_page=1&topic=".$post['Article_Topic']."\">".$post['Article_Topic']."</a>:</b>";
$_SESSION['Article_Story'][$i] = nl2br($post['Article_Story']);
$_SESSION['Article_Full'][$i] = nl2br($post['Article_Full_Story']);
$_SESSION['Article_Views'][$i] = $post['Article_Views'];
if($Censor_Words == 1){
$_SESSION['Article_Full'][$i] = censor($_SESSION['Article_Full'][$i]);
$_SESSION['Article_Story'][$i] = censor($_SESSION['Article_Story'][$i]);
}
if($Emoticon_On == 1){
$_SESSION['Article_Full'][$i] = emoticon($_SESSION['Article_Full'][$i]);
$_SESSION['Article_Story'][$i] = emoticon($_SESSION['Article_Story'][$i]);
}
$_SESSION['Comment_Count'][$i] = $MySQL->Rows("SELECT * FROM ".$pre."Article_Comments WHERE Story_ID = ".$_SESSION['Article_ID'][$i]."");
$_SESSION['Read_More'][$i] = "( <a href=\"index.php?find=News&Show_Full=1&ident=".$i."&Article_ID=".$_SESSION['Article_ID'][$i]."\">"._SEE_FULL_STORY."</a> | ";
$_SESSION['Read_More'][$i] .= _READS.": ". $_SESSION['Article_Views'][$i] . " | ";
$_SESSION['Read_More'][$i] .= "<a href=\"index.php?find=News&Show_Full=1&ident=".$i."&Article_ID=".$_SESSION['Article_ID'][$i]."#Post_Comment\">"._POST_COMMENT." [".$_SESSION['Comment_Count'][$i]."]</a> )";
$_SESSION['Article_Date'][$i] = $post['Article_Date'];
$_SESSION['Article_Author'][$i] = _POSTED_BY ." ". $post['Article_Author'];
$_SESSION['Art_Ses'][$i] = 1;
header("Location: index.php?find=News");
}
$user->theme("news.tpl", array("Article_Topic" => $_SESSION['Article_Topic'][$i], "Article_Title" => $_SESSION['Article_Title'][$i], "Article_Story" => $_SESSION['Article_Story'][$i], "Article_Author" => $_SESSION['Article_Author'][$i], "Article_Date" => $_SESSION['Article_Date'][$i], "Read_More" => $_SESSION['Read_More'][$i]));
$i++;
}
This is where the sessions are created, on the article script
$Table->Open();
echo "<div align=left>";
echo "<b>"._TITLE.":</b> ".$_SESSION['Article_Title'][$ident];
echo "<br><b>"._POSTED_ON.":</b> ".$_SESSION['Article_Date'][$ident];
echo "<br><b>"._AUTHOR.":</b> ".$_SESSION['Article_Author'][$ident];
echo "<br><b>"._READS.":</b> ".$_SESSION['Article_Views'][$ident]."<br><br>";
echo "<b>"._STORY.":</b> ".$_SESSION['Article_Story'][$ident];
if(!empty($_SESSION['Article_Full'][$ident])){
echo "<br><br><b>"._FULL_STORY.":</b> ".$_SESSION['Article_Full'][$ident];
}
echo "</div>";
$Table->Close();
$MySQL->Query("UPDATE ".$pre."News_Articles SET Article_Views=Article_Views+1 WHERE Article_ID = '".$Article_ID."'");
$_SESSION['Article_Views'][$ident]++;
echo "<br>";
Here is where the script updates the views for the article when viewed in full
if(isset($Confirm)){
if($user->lvl() == 99){
if(isset($Comment_ID)){
$Check_Comment_Exists = $MySQL->Fetch("SELECT * FROM ".$pre."Article_Comments WHERE Comment_ID = '".$Comment_ID."'");
if($Comment_ID == $Check_Comment_Exists['Comment_ID']){
$MySQL->Query("DELETE FROM ".$pre."Article_Comments WHERE Comment_ID = '".$Comment_ID."' LIMIT 1");
$_SESSION['Comment_Count'][$ident]--;
header("Location: index.php?find=News&Show_Full=1&ident=".$ident."&Article_ID=".$Article_ID."&Yes_Deleted=1");
}else{
header("Location: index.php?find=News&Show_Full=1&ident=".$ident."&Article_ID=".$Article_ID."&Not_Deleted=1");
}
}else{
header("Location: index.php");
}
}else{
header("Location: index.php");
}
}
Here is where it updates the number of comments when they are deleted
if($Submit){
if(empty($Comment_Content)){
echo _COMMENT_NOT_ADDED."<br><br>";
}elseif(isset($Comment_Content)){
if($user->id() > 1){
$name = $user->name();
}
$Insert_Comment = 'INSERT INTO `'.$pre.'Article_Comments` (`Comment_ID`, `Story_ID`, `Comment_Author`, `Comment_Date`, `Comment_Time`, `Comment_Content`) VALUES (\'\', \''.$Article_ID.'\', \''.$name.'\', \''.$date.'\', \''.time().'\', \''.$Comment_Content.'\')';
$MySQL->Query($Insert_Comment);
$_SESSION['Comment_Count'][$ident]++;
echo _COMMENT_ADDED."<br><br>";
}
}
And here is where it updates the comment total when they are posted
If you'll look, you will notice there are 2 sessions being updated
$SESSION['Comment_Count'][$ident']--;
$SESSION['Comment_Count'][$ident]++;
$_SESSION['Article_Views'][$ident]++;
The $ident variable holds the $i variables for each article on the main page, and then is used to call back the session for that article, that way there is NEVER any other article searching with mysql until there is an update.
These sessions are the same as the originals created, however, when they are updated they only show on the page where they are updated, how can I get them to show on all the other pages too?
P.S. to see an example of what I am talking about visit http://timtimtimma.com/ and find an article you like on the front page take note on how many "Reads" it has displayed on the front page. Then click "Read More" and view the article on the next page, refresh a few times, and you will notice that the article reasons updates and goes up as it should, but when you go to visit the 'Home' and view the same article on the front page the "Reads is where it was originally and has NOT changed"