I use MySQL & PHP and have the following database requests:
$result1 = mysql_query("SELECT nummer FROM abo WHERE usr = '{$usr}'");
while($row = mysql_fetch_object($result1))
{
$sendung=$row->sendung;
$result2 = mysql_query("SELECT *
FROM filme
WHERE sendung = '{$sendung}'
ORDER BY datum DESC LIMIT 0,1;");
while($row = mysql_fetch_object($result2))
{
[...]
}
}
For example there the second while is called 20 times -> there are 20 database request. But could I connect this request or optimize this requests?
One approach:
$arraysendung = array();
$result1 = mysql_query("SELECT nummer FROM abo WHERE usr = '{$usr}'");
while($row = mysql_fetch_object($result1))
{
array_push($arraysendung,$row->sendung);
}
But how could I use $arraysendung
in one request (is it possible)?