Count pages?

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

    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.

    #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...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


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

      Comment


        #4
        nice thana, karerabet *think*
        Did I help you?
        You can help me too
        Your donations will help me finance my studies.

        Comment


          #5
          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.

          Comment


            #6
            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.

            Comment

            Working...
            X