pandailo Posted October 23, 2007 Share Posted October 23, 2007 Dear all, I have this php code but i failed to get Next and Prev working in this code. can anybody modified this code myscript.php if($action=="viewcat") { $cid = $_GET["cid"]; addonline(getuid_sid($sid),"Viewing Forum Category","forum.php?action=viewcat&cid=$cid"); $cinfo = mysql_fetch_array(mysql_query("SELECT name from ibwf_fcats WHERE id='".$cid."'")); //////ALL LISTS SCRIPT if($page=="" || $page<=0)$page=1; $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_forum")); $num_items = $noi[0]; //changable $items_per_page= 5; $num_pages = ceil($num_items/$items_per_page); if(($page>$num_pages)&&$page!=1)$page= $num_pages; $limit_start = ($page-1)*$items_per_page; echo "<card id=\"main\" title=\"$cinfo[0]\">"; echo popup($sid); $forums = mysql_query("SELECT id, name FROM ibwf_forums WHERE cid='".$cid."' AND clubid='0' ORDER BY position, id, name LIMIT $limit_start, $item_per_page"); echo "<p align=\"left\">"; while($forum = mysql_fetch_array($forums)) { $notp = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_topics WHERE fid='".$forum[0]."'")); $nops = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts a INNER JOIN ibwf_topics b ON a.tid = b.id WHERE b.fid='".$forum[0]."'")); $iml = "<img src=\"../images/1.gif\" alt=\"*\"/>"; echo "<a href=\"forum.php?action=viewfrm&sid=$sid&fid=$forum[0]\">$iml$forum[1]($notp[0]/$nops[0])</a><br/>"; $lpt = mysql_fetch_array(mysql_query("SELECT id, name FROM ibwf_topics WHERE fid='".$forum[0]."' ORDER BY lastpost DESC LIMIT 0,1")); $nops = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE tid='".$lpt[0]."'")); if($nops[0]==0) { $pinfo = mysql_fetch_array(mysql_query("SELECT authorid FROM ibwf_topics WHERE id='".$lpt[0]."'")); $tluid = $pinfo[0]; }else{ $pinfo = mysql_fetch_array(mysql_query("SELECT uid FROM ibwf_posts WHERE tid='".$lpt[0]."' ORDER BY dtpost DESC LIMIT 0, 1")); $tluid = $pinfo[0]; } $tlnm = htmlspecialchars($lpt[1]); $tlnick = getnick_uid($tluid); $tpclnk = "<a href=\"forum.php?action=viewtpc&sid=$sid&tid=$lpt[0]&go=last\">$tlnm</a>"; $vulnk = "<a href=\"setting.php?action=viewuser&sid=$sid&who=$tluid\">$tlnick</a>"; if ($pinfo[0]>0) { echo "Last post: $tpclnk<br/>Posted by: $vulnk<br/>"; } } echo "</p>"; echo "<p align=\"center\">"; $tmsg = getpmcount(getuid_sid($sid)); $umsg = getunreadpm(getuid_sid($sid)); if($umsg>0) { echo "<br/><a href=\"inbox.php?action=main&sid=$sid\">Inbox($umsg/$tmsg)</a><br/>"; } echo "</p>"; echo "<p align=\"center\">"; if($page>1) { $ppage = $page-1; echo "<a href=\"lists.php?action=$action&page=$ppage&sid=$sid&view=$view\">Prev</a> "; } if($page<$num_pages) { $npage = $page+1; echo "<a href=\"lists.php?action=$action&page=$npage&sid=$sid&view=$view\">Next</a>"; } echo "<br/>$page/$num_pages<br/>"; if($num_pages>2) { $rets = "Jump to page<input name=\"pg\" format=\"*N\" size=\"3\"/>"; $rets .= "<anchor>[GO]"; $rets .= "<go href=\"lists.php\" method=\"get\">"; $rets .= "<postfield name=\"action\" value=\"$action\"/>"; $rets .= "<postfield name=\"sid\" value=\"$sid\"/>"; $rets .= "<postfield name=\"page\" value=\"$(pg)\"/>"; $rets .= "</go></anchor>"; echo $rets; } echo "</p>"; echo "<p align=\"center\">"; echo "<br/><a href=\"index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>"; echo "</p>"; echo "</card>"; } Quote Link to comment https://forums.phpfreaks.com/topic/74428-solved-next-and-prev-not-working/ Share on other sites More sharing options...
sasa Posted October 23, 2007 Share Posted October 23, 2007 try echo "<a href=\"lists.php?action=$action&page=$npage&sid=$sid&view=$view\">Next</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/74428-solved-next-and-prev-not-working/#findComment-376028 Share on other sites More sharing options...
pandailo Posted October 23, 2007 Author Share Posted October 23, 2007 also not working...the problem is button Next and Prev not appear.. Quote Link to comment https://forums.phpfreaks.com/topic/74428-solved-next-and-prev-not-working/#findComment-376035 Share on other sites More sharing options...
pandailo Posted October 23, 2007 Author Share Posted October 23, 2007 my $num_pages is empty or 0 but i have a item in the mysql database Quote Link to comment https://forums.phpfreaks.com/topic/74428-solved-next-and-prev-not-working/#findComment-376038 Share on other sites More sharing options...
pandailo Posted October 23, 2007 Author Share Posted October 23, 2007 i got this error message in apache PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/myscript.php on line 142, Quote Link to comment https://forums.phpfreaks.com/topic/74428-solved-next-and-prev-not-working/#findComment-376042 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.