Форум -> Обо всём... -> помогите вывести страницы | помогите вывести страницы |
---|
rocksmart | Дата: 15.06.2008, в 12:10 | Сообщение №1 | СтарожилПользователь №: 261 Сообщений: 330
| Сделал для форума новую функцию типа новые сообщения где новые выодяться на первой странице.
Но не могу сделать постраничнуб навигацию так тройной запрос к таблицам меня ставит в тупик.
Код | 1
| <?php
if (!defined("FUNC_FILE")) die("Illegal File Access");
function new1(){
global $prefix, $db,$spbconf,$pagenum,$filenum;
$storynum =5;
$pagenum = (!intval($pagenum)) ? 1 : intval($pagenum);
$offset = ($pagenum-1) * $storynum;
$offset = intval($offset);
smarthead();
sp_open_m("Новые сообщения");
echo"<font class=\"smalla\">";
$userinfo = getusrinfo();
$uname = $userinfo['user_name'];
$user_id = intval($userinfo['user_id']);
$lastvisit = $userinfo['user_lastvisit'];
if (is_user($user)) {
if (is_admin($admin))
$userstatus=10;
else
{
$sqlinfo="select user_forum_moder from ".$prefix."_users where user_id='".$user_id."'";
$resinfo=$db->sql_query($sqlinfo);
$rowinfo=$db->sql_fetchrow($resinfo);
$status=$rowinfo['user_forum_moder'];
if ($status==1) { $userstatus=5; } else { $userstatus=0; }
}
}
if (!isset($userstatus))
$userstatus=0;
$sql_last="SELECT t.id tid, t.name tname, t.tdesc tdesc, t.user user, t.last_user tuser, t.forum fid, t.visits visits, t.totalposts tposts, t.last_post tlastpost,c.name cname,f.name fname,f.fdesc ffdesc FROM ".$prefix."_forum_topics t, ".$prefix."_forum_forums f, ".$prefix."_forum_cats c
WHERE f.id=t.forum AND c.id=f.cat AND c.stats<='".$userstatus."'
ORDER BY t.last_post DESC LIMIT $offset, $storynum";
$res_last=$db->sql_query($sql_last);
while ($row=$db->sql_fetchrow($res_last))
echo"<hr>".$row["fname"]." <br><a href=\"index.php?name=smartforums&op=shownewpost&id=".$row["tid"]."\" title=\"".$row['tdesc']."\">".cutstr($row['tname'], 45)."</a> ".$row["tdesc"]." (отв ".$row['tposts'].")<br>
<a href='index.php?name=smartforums&op=showlastpost&id=".$row['tid']."'>Последний</a>: <a target=\"_blank\" href=\"index.php?name=SmartAccount&op=info&uname=".$row['tuser']."\"><b>".$row['tuser']."</b></a> ".formatpostdate($row['tlastpost'])."";
echo"<br>";
list($numstories) = $db->sql_fetchrow($db->sql_query("SELECT Count( t.id) as tid FROM ".$prefix."_forum_topics t WHERE t.id = '".$row['tid']."' AND status !='0'")); $numpages = ceil($numstories / $filenum);
num_page(smartforums, $numstories, $numpages, $filenum, "op=new1=".$row['tid']."");
echo"</font>";
smartfoot();
}
?> |
|
| | | Serg_pnz | Дата: 16.06.2008, в 09:29 | Сообщение №2 | АдминистраторПользователь №: 1 Сообщений: 2242
| Если ты про SSDF, то запросы можно посмотреть в функции showforum при условии id=0
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Отредактированно Serg_pnz 16.06.2008 г. в 09:29:45 | Не все кальсоны с оторванными пуговицами - брюки. © Serg_pnz
"...даме водки? Это чистый спирт!" © кот Бегемот |
| | | Вы не можете ответить в тему анонимно, пожалуйста, войдите или зарегистрируйтесь!
|
|