Results 1 to 3 of 3

Thread: count rows and then use them

  1. #1
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default count rows and then use them

    Hello, I just got a fast question. If I wanna check how many rows I selected I got to use "select COUNT(*) as numbers_of_rows" but I cant use the info inside the COUNT then so do I have to use select twice (one for count and once without count) or is there another way to do this?

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Use:
    Code:
    $query = "SELECT * FROM mydatabase";
    $number = mysql_num_rows(mysql_query($query));
    $number will have the number of rows starting at 1. You will often havet o subtract 1 when encorperating into query strings, seeings that index starts at 0.
    - Mike

  3. #3
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you, that helped a lot.

Bookmarks

Posting Permissions

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