Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT FOUND_ROWS() Question

Status
Not open for further replies.

rvr1

Programmer
Feb 6, 2004
16
NL
I have the following query:

$sql = "SELECT product_name FROM products,product_brand_category WHERE products.product_id = product_brand_category.product_id AND brand_id='9' AND category_id='5'";

$result = mysql_query($sql)
or die ("Could not execute query" . mysql_error());

while ($row = mysql_fetch_array($result))
{
extract($row);
echo"$product_name";
}

What I would like to do is have some way of finding out how many rows match the search criteria and being able to assign this value to a variable, but without having to actually process every row.

I think it can be done with SELECT FOUND_ROWS(), however am not sure how. Can anyone five me some pointers please?

Thanks!
 
This is a PHP question--

[tt]
$result = mysql_query($sql)
or die ("Could not execute query" . mysql_error());

$num_rows = mysql_num_rows($result);
[/tt]

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top