Jump to content


Photo

Help with a code.


  • Please log in to reply
2 replies to this topic

#1 Birdman203

Birdman203
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 02 July 2006 - 07:50 PM

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:
<?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');


?>


#2 karthikeyan_coder

karthikeyan_coder
  • Members
  • PipPipPip
  • Advanced Member
  • 201 posts

Posted 02 July 2006 - 08:30 PM

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....
www.karthi.us

#3 Birdman203

Birdman203
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 02 July 2006 - 11:15 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users