Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts

    display total records onto page

    Ok on the admin side of the content management system im building, I have a fille called "view_users.php", which will diplay a list of all the users who are registered in the db. What I am wondering is how I would go about setting up a query or whatever to look at the total number of records and return it to the page so that I could have something on my page say "645,527 members and counting"

    thanks for the help

  • #2
    Regular Coder BWiz's Avatar
    Join Date
    Mar 2006
    Location
    Sol System
    Posts
    471
    Thanks
    7
    Thanked 21 Times in 21 Posts
    PHP Code:
    $link = @mysql_connect "localhost""user""pass" )
        or die ( 
    mysql_error() );
    $db = @mysql_select_db "databaseName"$link )
        or die ( 
    mysql_error() );
    $query mysql_query "SELECT * FROM tableName WHERE 1" );
    $count mysql_fetch_rows $query );

    print 
    $count
    I think this works, I'm not sure, haven't tested.
    BWiz :: Happy Coding!
    2006
    2007 2008 2009
    2010 2011
    Irrational numbers make no sense.

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts
    After making the needed changes this is the error I get...

    Fatal error: Call to undefined function mysql_fetch_rows() in C:\xampp\htdocs\viewable\hsrevised\cms\admin\view_users.php on line 7
    Here is my code as of now
    PHP Code:
    $link = @mysql_connect "localhost""root""" )
        or die ( 
    mysql_error() );
    $db = @mysql_select_db "reg"$link )
        or die ( 
    mysql_error() );
    $query mysql_query "SELECT * FROM users WHERE 1" );
    $count mysql_fetch_rows $query );

    print 
    $count
    Figured one thing out. I replaced mysql_fetch_rows with "mysql_num_rows" and that brought back a number. Now how would I put the message after it to finish it off?

    Thanks for your help
    Last edited by wayne3503; 08-01-2007 at 04:16 PM.

  • #4
    Regular Coder BWiz's Avatar
    Join Date
    Mar 2006
    Location
    Sol System
    Posts
    471
    Thanks
    7
    Thanked 21 Times in 21 Posts
    Sorry, I think I had a mind block! Its actually: mysql_num_rows.
    BWiz :: Happy Coding!
    2006
    2007 2008 2009
    2010 2011
    Irrational numbers make no sense.

  • #5
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I figured out the message part now to...Thanks for the start


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •