Jump to content

Archived

This topic is now archived and is closed to further replies.

Birdman203

Help with a code.

Recommended Posts

I can not figure what is wrong with this code. When it goes to index.php it shows the news the ammount of news specified by $config[news] which is 5, but when it goes to index.php?page=2 it doesn't show anything. And even the $count is set to 0, but really it's not.

Here is the code:
[code]
<?php
require 'required.inc.php';


$news = $config[news];
$page = $_REQUEST['page'];
$mul2 = bcmul($page, $news);
$mul = bcsub($mul2, $news);
if (isset($page)) {
$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$congig[news_cat]' order by id desc limit $mul , $news") or die(mysql_error());
} else {
$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$config[news_cat]' order by id desc limit 0, $news") or die(mysql_error());
}
$count = mysql_num_rows($result);
if ($count > $mul) {
$smarty->assign("nextp", 1);
}
if ($count < $mul) {
$smarty->assign("backp", 1);
}
$i = 0;
while ($row = mysql_fetch_array($result)) {
$result2 = mysql_db_query("typekill_global", "select * from cp_members where alias = '$row[author]'") or die(mysql_error());
$qry = mysql_fetch_array($result2);
$cresult = mysql_db_query("typekill_$config[short]", "select * from cp_fposts where topic_id = '$row[id]'") or die(mysql_error());
$row2 = mysql_fetch_array($cresult);
$comments2 = mysql_num_rows($cresult);
$comments = bcsub($comments2, 1);
$time = date("M d Y, h:i:s a", "$row[date]");
$news = array(
'id' => $row[id],
'title' => $func->outp($row[title]),
'date' => $time,
'message' => $func->outp($row2[message]),
'readmore' => $func->outp($row2[readmore]),
'author' => array(
'id' => $qry[member_id],
'firstname' => $qry[firstname],
'lastname' => $qry[lastname],
'alias' => $qry[alias],
'country' => $qry[country]),
'comments' => $comments
);
$news2[$i++] = $news;
}
$smarty->assign("main_news", $news2);

$smarty->display('index.tpl');


?>
[/code]

Share this post


Link to post
Share on other sites
Try to use session variables in all of your pages..

$news
$page
$mul2
$mul

store those values in a session variable.. and use it... try to apply this idea....

Share this post


Link to post
Share on other sites
I fixed it and the funny thing was I didn't have to use SESSIONS or anything like that. I just had to rewrite the line and it worked.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.