I have a portfolio which is showing results from my database... I need to know how to find out if there's more than one of the items with the same owner using an if statement...
It's not advanced I just have a table with the company name, website address etc. and at the end a column that's named "owner" which has the owners email address...
I need to find out if there's more than one portfolio item with the same email address
Please Help
Thanks Ben
Update: mysql_num_rows($result) is the answer
So, your table looks like this:
portfolio
=============
company
url
owner
A SQL query to retrieve the number of portfolio items per owner:
SELECT COUNT(*) as Num_Portfolio_Items, owner FROM portfolio GROUP BY owner;
If I understand your question correctly you should use COUNT
in your SQL statement:
$email = 'some.email@address.com';
$query = mysql_query(sprintf('SELECT COUNT(1) FROM your_table WHERE owner = "%s"', $email));
$rs = mysql_fetch_row($query);
echo "There are " . $rs[0] . " people with " . $email . " email address.";