Forum topic views

532
.
Anyone know how to make when you are looking topics on any category and next to theme name to write number of times topic viewed?
.
EcHo_Texas
Add in your sql db
ALTER TABLE `forum` ADD `view` int(11) NOT NULL default '0';


Find this
echo '</p>';
if (!$user_id) {
if ((empty($_SESSION['uppost'])) || ($_SESSION['uppost'] == 0)) {
echo '<a href="index.php?id=' . $id . '&page=' . $page . '&newup">' . $lng_forum['new_on_top'] . '</a>';
} else {
echo '<a href="index.php?id=' . $id . '&page=' . $page . '&newdown">' . $lng_forum['new_on_bottom'] . '</a>';
}
}
}


Add in bottom
mysql_query("UPDATE forum SET view = view + 1 WHERE id = $id");


Find again:
echo '<div class="phdr"><a name="up" id="up"></a><a href="#down"><img src="../theme/' . $set_user['skin'] . '/images/down.png" alt="????" width="20" height="10" border="0"/></a>  <b>' . $type1['text'] . '</b></div>';


Replace with
echo '<div class="phdr"><a name="up" id="up"></a><a href="#down"><img src="../theme/' . $set_user['skin'] . '/images/down.png" alt="????" width="20" height="10" border="0"/></a>  <b>' . $type1['text'] . '|'.$type1['view'].' Views </b></div>';


DONE
.
It counts for every topic, when i view one topic, it gives +1 view to all topics in that category
.
I making in categories where it shows list of topics under name of topic shows number of views, but when i visit one topic it counts for all topics
.
It works in topic but how can it show in list of topics number of views?
.
SpAgEtE
Never mind i figured it, just in list of topics type
' . $res['view'] . '

and also for counting views i added it in line
// Выводим название топика

not on bottom because when i place in bottom it counts for viewing categories of forum

Thanks bro
.
I want to make themes order by views except i dont know how to make it to read from views not time
.
Here is my code for last themes
$kmessreq= 6;
$startreq = isset($_REQUEST['page']) ? $page * $kmessreq - $kmessreq : (isset($_GET['start']) ? abs(intval($_GET['start'])) : 0); 
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type` = 't' and `kedit`='0' AND `close`!='1' "), 0); 
$req = mysql_query("SELECT * FROM `forum` WHERE `type` = 't' and kedit='0' AND `close`!='1' ORDER BY `time` DESC LIMIT $startreq, $kmessreq"); 
while ($arr = mysql_fetch_assoc($req)) { 
$nikuser = mysql_query("SELECT `from`,`id`, `time` FROM `forum` WHERE `type` = 'm' AND `close` != '1' AND `refid` = '" . $arr['id'] . "' ORDER BY time DESC"); 
$colmes1 = mysql_num_rows($nikuser); 
$cpg = ceil($colmes1 / $kmess); 
$nam = mysql_fetch_assoc($nikuser);
echo '<div class="teme">';

echo '</b>';
echo '&nbsp;<a href="forum/index.php?id=' . $arr['id'] . '">' . $arr['text'] . '</a> [' . $colmes1 . ']';
if ($cpg > 1)
echo '<a href="forum/index.php?id=' . $arr['id'] . '&amp;page=' . $cpg . '">&gt;&gt;</a>';
if ($colmes1 > 1){
echo ' <font color="red">~ '.$nam['from'].' </font>';
}else
echo ' <font color="red">~ '.$arr['from'].'</font>';
echo '<br/><span class="gray">(' . functions::display_date($arr['time']) . ')</span> | <span class="gray">Pregleda: ' . $arr['view'] . '</span>';


echo '</div>';
}


Anyone know how to order by views?
Всего: 8