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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php querying mysql !!

    Hey everyone

    If I have a simple query such as

    select name from tableone where name = whatever

    How can I add on a count to the end of it. In other word have something that counts the reords returned and puts that value into a variable, e.g $counttotal

    Any help appreaciated ??


  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Here's one way.
    Code:
    $result=mysql_query("SELECT count(name) FROM tableone WHERE name=whatever",$linID);
    $tot=mysql_fetch_association($result);
    I believe there's also a mysql_num_rows which gives you the total rows returned from a result set.

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks bcarl

    Just what I was after !!



  •  

    Posting Permissions

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