Birdman203 Posted July 2, 2006 Share Posted July 2, 2006 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]<?phprequire '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] Quote Link to comment https://forums.phpfreaks.com/topic/13489-help-with-a-code/ Share on other sites More sharing options...
karthikeyan_coder Posted July 2, 2006 Share Posted July 2, 2006 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.... Quote Link to comment https://forums.phpfreaks.com/topic/13489-help-with-a-code/#findComment-52198 Share on other sites More sharing options...
Birdman203 Posted July 2, 2006 Author Share Posted July 2, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/13489-help-with-a-code/#findComment-52248 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.