myrveln
11-05-2007, 12:08 PM
Hey
I have a feeling that this isnīt very optimal. Is there a way where you can put all these mysql queries into one or more fewer than this?
This way works great, though a bit too much queries.
Any ideas appreciated.
$querytotal = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND visible='0'");
$numtotal = mysql_num_rows($querytotal);
$query_1 = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND type='1' AND visible='0'");
$num1 = mysql_num_rows($query_1);
$query_2 = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND type='2' AND visible='0'");
$num2 = mysql_num_rows($query_2);
$query_3 = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND type='3' AND visible='0'");
$num3 = mysql_num_rows($query_3);
if($numrow > 0){
print "Print out the content\n\n";
}
I have a feeling that this isnīt very optimal. Is there a way where you can put all these mysql queries into one or more fewer than this?
This way works great, though a bit too much queries.
Any ideas appreciated.
$querytotal = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND visible='0'");
$numtotal = mysql_num_rows($querytotal);
$query_1 = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND type='1' AND visible='0'");
$num1 = mysql_num_rows($query_1);
$query_2 = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND type='2' AND visible='0'");
$num2 = mysql_num_rows($query_2);
$query_3 = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND type='3' AND visible='0'");
$num3 = mysql_num_rows($query_3);
if($numrow > 0){
print "Print out the content\n\n";
}