Counting entries: php / mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • d3vkit
    New Member
    • Nov 2006
    • 34

    Counting entries: php / mysql

    Edit: Gosh I should really sleep. I was looking at my article numbers, not my ACTUAL DB numbers; seems I had deleted some blogs or something but it kept marching forward, so there was a discrepancy between article numbers vs actual blogid. So, if a mod can delete this, I'd be fine with that (I guess I can't delete the thread). Thanks for any time anyone spent reading this.


    I am for some reason not getting this, and maybe someone else can see what I'm doing wrong. I am trying to add pagination to my website, and everything is pretty good except the count of my blog entries is wrong; I have 143 and it says 124 total.

    Here's what I mean:
    [PHP]
    $nav_sqlcount = "SELECT count(*) FROM blog";
    $getcount = mysql_query($na v_sqlcount) or die('problem getting count: '.mysql_error() );
    $total_results = mysql_result($g etcount, 0) or die('problem getting total results: '.mysql_error() );
    echo $total_results;
    [/PHP]

    Now my understanding is that it first is getting the count of all (*) entries in the blog table, and then creating a readable result with mysql_result, beginning at row 0. So why is it coming up as 124 instead of 143 when I echo $total_results? Am I misunderstandin g what's happening here?
    Last edited by d3vkit; Aug 11 '07, 11:50 AM. Reason: Stupidity
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    That looks right. Are you sure you have 143 records, and not 124?

    Comment

    Working...