Hi!
I am having the following code which will query the database as many times as there are elements in the array, depending on the number of elements any results this may take quite some time. Now I wonder if there is any way to make this code more effective (i.e. somehow just do one query)?
I am using a MySQL-Database and PHP3.
Ciao
Sascha
$myarray = array("2"=>"Albania","7"=>"Armenia","9"=>"Austria");
for(reset($myarray); $key = key($myarray); next($myarray)) {
print "<td align='right'><a href='http://www.phpbuilder.com/board/archive/index.php/cat.php3?l=$key'>$myarray[$key]</a></td>
<td>: ";
$query = "SELECT * FROM $table WHERE country = '$key'";
$result = mysql_db_query("$DB", $query);
$number = mysql_num_rows($result);
print "$number</td></tr><tr>";
}
I am having the following code which will query the database as many times as there are elements in the array, depending on the number of elements any results this may take quite some time. Now I wonder if there is any way to make this code more effective (i.e. somehow just do one query)?
I am using a MySQL-Database and PHP3.
Ciao
Sascha
$myarray = array("2"=>"Albania","7"=>"Armenia","9"=>"Austria");
for(reset($myarray); $key = key($myarray); next($myarray)) {
print "<td align='right'><a href='http://www.phpbuilder.com/board/archive/index.php/cat.php3?l=$key'>$myarray[$key]</a></td>
<td>: ";
$query = "SELECT * FROM $table WHERE country = '$key'";
$result = mysql_db_query("$DB", $query);
$number = mysql_num_rows($result);
print "$number</td></tr><tr>";
}