Count pages?

Started on the old forum in December 2009 · view the original in the archive · old links redirect here

5 replies · 396 views · started 16 years ago · 1 min read

4 participants
thanatos Senior · 261 posts #1

I need help in getting the items per page.

here's the code:

$noi = mysql_fetch_array(mysql_query("SELECT COUNT() FROM ibwf_karerabet")); $num_items = $noi[0]; //changable $items_per_page= 10; $num_pages = ceil($num_items/$items_per_page); if(($page>$num_pages)&&$page!=1)$page= $num_pages; $limit_start = ($page-1)$items_per_page;

//changable sql
    $sql = " SELECT uid, COUNT(*) as nopl, combination, COUNT(*) as notl FROM ibwf_karerabet GROUP BY uid, combination ORDER BY time DESC LIMIT $limit_start, $items_per_page";
$cou = $limit_start;

echo " "; $items = mysql_query($sql); echo mysql_error(); if(mysql_num_rows($items)>0) { while ($item = mysql_fetch_array($items)) { $cou++; $unick = getnick_uid($item[0]); $nm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_karerabet WHERE uid='".$item[0]."' AND combination='".$item[2]."'")); $lnk = "$cou. $unick: $item[2] ($nm[0])"; echo "$lnk "; } }

My problem here really is this line:

$noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_karerabet"));

thanks in advance. 😊

subzero Super moderator Fellow · 3,954 posts #2

COUNT(*) is no need if your lookin for pages

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

kei_ki7 Senior · 431 posts #4

nice thana, karerabet think

Did I help you? You can help me too Your donations will help me finance my studies.

huwad Developer · 215 posts #5

thanatos wrote: I need help in getting the items per page.

here's the code:

My problem here really is this line:

thanks in advance. 😊

thanatos?? uhhm.. hows your site?? natasu??

$noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_karerabet"));
$num_items = $noi[0]; //changable
$items_per_page= 10;
$num_pages = ceil($num_items/$items_per_page);
if(($page>$num_pages)&&$page!=1)$page= $num_pages;
$limit_start = ($page-1)*$items_per_page;

//changable sql
$sql = " SELECT uid, COUNT(*) as nopl, combination, COUNT(*) as notl FROM ibwf_karerabet GROUP BY uid, combination ORDER BY time DESC LIMIT $limit_start, $items_per_page";
$cou = $limit_start;
echo "<p>";
$items = mysql_query($sql);
echo mysql_error();
if(mysql_num_rows($items)>0)
{
while ($item = mysql_fetch_array($items))
{
$cou++;
$unick = getnick_uid($item[0]);
$nm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_karerabet WHERE uid='".$item[0]."' AND combination='".$item[2]."'"));
$lnk = "$cou. $unick: <b>$item[2]</b> ($nm[0])";
echo "$lnk<br/>";
}
}

[COLOR="Red"]

if($page=="" || $page<=0)$page=1;
$noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_karerabet));
$num_items = $noi[0];
$items_per_page= [b]10[/b];
$num_pages = ceil($num_items/$items_per_page);
if(($page>$num_pages)&&$page!=1)$page= $num_pages;
$limit_start = ($page-1)*$items_per_page;
}
if($page>1)
{
$ppage = $page-1;
echo "<a href=\"file.php?action=command\">«PREV</a> ";
}
if($page<$num_pages)
{
$npage = $page+1;
echo "<a href=\"file.php?action=command\">Next»</a>";
}
echo "<br/>$page/$num_pages<br/>";
if($num_pages>2)
{
$rets = "<form action=\"file.php\" method=\"get\">";
$rets .= "Jump to page<input name=\"page\" format=\"*N\" size=\"3\"/>";
$rets .= "<input type=\"submit\" value=\"GO\"/>";
$rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
$rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
$rets .= "</form>";

echo $rets;
}[/COLOR]

hacking is like sex. you get in, you get out and you pray you left nothing behind.

thanatos Senior · 261 posts #6

huwad wrote: thanatos?? uhhm.. hows your site?? natasu??

💬

back to the topic. i tried this sub but it didnt work.

$abcs = mysql_query("SELECT combination, uid FROM ibwf_karerabet"); while($abc=mysql_fetch_array($abcs)) { $ftg = $abc[0]; $gtg = $abc[1]; } $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_karerabet WHERE combination='".$ftg."' AND uid='".$gtg."'")); $num_items = $noi[0]; //changable

Pipol, a little help here will be appreciated. pls do not jump to other topics. thanks.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close