Count pages?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • thanatos
    replied
    Originally posted by huwad View Post
    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.

    Leave a comment:


  • huwad
    replied
    Originally posted by thanatos View Post
    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??

    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 "<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]
    Last edited by huwad; 11.12.09, 09:26.

    Leave a comment:


  • kei_ki7
    replied
    nice thana, karerabet *think*

    Leave a comment:


  • thanatos
    replied
    Originally posted by subzero View Post
    COUNT(*) is no need if your lookin for pages
    so how can i solve it?

    Leave a comment:


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

    Leave a comment:


  • thanatos
    started a topic Count pages?

    Count pages?

    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 "<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/>";
    }
    }
    My problem here really is this line:
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_karerabet"));
    thanks in advance.
Working...
X