Takara
08-08-2003, 03:26 AM
I have 3 queries that are pretty much the same, each one just gets the total amount of rows that match a certin criteria. But I'm wondering if there is a way to merge the 3 queries into 1, this is the code I'm using:
$q="SELECT count(*) from tracker where viewed=0";
$result= mysql_db_query($dbase, $q, $connection) or die ("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) { $out = $row[0]; }
$q="SELECT count(*) from tracker where viewed=1 and status=0";
$result= mysql_db_query($dbase, $q, $connection) or die ("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) { $pen = $row[0]; }
$q="SELECT count(*) from tracker";
$result= mysql_db_query($dbase, $q, $connection) or die ("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) { $tot = $row[0]; }
Any help would be really appreciated. Thanks
$q="SELECT count(*) from tracker where viewed=0";
$result= mysql_db_query($dbase, $q, $connection) or die ("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) { $out = $row[0]; }
$q="SELECT count(*) from tracker where viewed=1 and status=0";
$result= mysql_db_query($dbase, $q, $connection) or die ("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) { $pen = $row[0]; }
$q="SELECT count(*) from tracker";
$result= mysql_db_query($dbase, $q, $connection) or die ("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result)) { $tot = $row[0]; }
Any help would be really appreciated. Thanks