Rather than typing out the same query (with one exception), I want to have a series of "if" statements and based on that, do something. Is it possible to have multiple while statements?
For example:
Here's a query:
SELECT groceries.Groceries,
groceries.Store,
COUNT(purchases.Produce) as countviews,
COUNT(purchases.Meat) as countclicks
FROM groceries, purchases
WHERE groceries.ID = purchases.ID
GROUP BY groceries.Groceries
ORDER BY groceries.Store;
And the code:
if ( mysql_num_rows ( $sql ) > 0 ) {
echo "<tr><td>SAFEWAY</td></tr>";
while ( $row = mysql_fetch_array ( $sql, MYSQL_ASSOC ) ) {
if(eregi("Safeway",$row['Store'])) {
DO SOMETHING
}
}
echo "<tr><td>VONS</td></tr>";
while ( $row = mysql_fetch_array ( $sql, MYSQL_ASSOC ) ) {
if(eregi("Vons",$row['Store'])) {
DO SOMETHING
}
}
}
I've been trying to do this, and the second while statement doesn't execute at all. So, now I'm wondering if this is possible?