#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    14
    I would like to know if anyone can show me how to count search results in a MySQL database for a keyword ($keyword). Thanks in advance.


    Thanks,
    Scott Lee
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Indonesia
    Posts
    87
    Rep Power
    14
    you can use
    mysql_num_rows($result);

    it will return the number of the query result

    See ya

    ------------------
    CyberOsc
    sphmjf_oscario@gurlmail.com

    ** It's the world of Oscario **
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    14
    I know that, but how can I assign that number to a variable so i could put something like:
    print("$results results found for $keyword");


    Thanks,
    Scott
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Seaside, CA
    Posts
    84
    Rep Power
    14
    I think this will work. In your select statement, use something like:

    "SELECT fieldname, COUNT(*) as fieldttl FROM yourtablename WHERE fieldname = 'whatever' GROUP BY fieldname"

    Then you can use $fieldname and $fieldttl as variables.

    ------------------
    From the day we're born, we're running out of time.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Canada
    Posts
    35
    Rep Power
    14
    I know that, but how can I assign that number to a variable so i could put something like:
    print("$results results found for $keyword");
    --------------------------------------------------------------
    $results=mysql_num_rows($result);

    print("$results results found for $keyword");

    Hope this helps!
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    14
    thanks guys, i'll try it out, if i can't get it to work, i don't need it until i completely understand it =)

    Thanks,
    scott

Similar Threads

  1. Cgi Search feature script
    By butsy_7 in forum Perl Programming
    Replies: 5
    Last Post: January 22nd, 2004, 07:43 PM
  2. How can I perform a search with a previous search results?
    By charlie_tango in forum MySQL Help
    Replies: 1
    Last Post: January 17th, 2004, 10:06 AM
  3. search results errors!
    By clue05 in forum PHP Development
    Replies: 2
    Last Post: January 16th, 2004, 11:18 AM
  4. Using sessions for search / results pages
    By Quirk in forum PHP Development
    Replies: 10
    Last Post: December 15th, 2003, 08:36 PM
  5. Google search results
    By webwonderuk in forum Search Engine Optimization
    Replies: 5
    Last Post: November 28th, 2003, 02:25 AM

IMN logo majestic logo threadwatch logo seochat tools logo