MySQL + PHP - Search Engine question!

2005-01-31 Thread Matt Babineau
Hi All -

I'm building a search engine and what I would like to do is run a search and
get the number of results, but still use the LIMIT command so I am not
returning a ton of rows all at once.

Is this the best way to go about searching?

Thanks,

Matt Babineau
Criticalcode
w: http://www.criticalcode.com
p: 858.733.0160
e: [EMAIL PROTECTED]



Re: Mysql + PHP - Search

2005-01-31 Thread Matt Babineau
I just answered my own question actually!

- snip from php.net -
MySQL 4.0 supports a fabulous new feature that allows you to get the number
of rows that would have been returned if the query did not have a LIMIT
clause. To use it, you need to add SQL_CALC_FOUND_ROWS to the query, e.g.

$sql = Select SQL_CALC_FOUND_ROWS * from table where state='CA' limit 50;
$result = mysql_query($sql);

$sql = Select FOUND_ROWS();
$count_result = mysql_query($sql);

You now have the total number of rows in table that match the criteria. This
is great for knowing the total number of records when browsing through a
list.
--

Matt Babineau
Criticalcode
w: http://www.criticalcode.com
p: 858.733.0160
e: [EMAIL PROTECTED]