After the first iteration of the first loop, the internal pointer of the second result set is at the end, so the second loop will not execute, because mysql_fetch_array()
will return false
immediately. If you want to it exactly as above - the second result set is not dependant on the first - you will need to do this:
// First, get the results of set 2 into an array
$resultset2 = array();
while ($row = mysql_fetch_assoc($result2)) $resultset2[] = $row;
while ($row = mysql_fetch_assoc($result)) { // Do your thang
echo "<li class=\"s01\"><a class=\"s03\" href=" . $row['link'] . "><span>".$row['onomaselidas'] ."</span></a>\n";
echo "<ul class=\"pn2\">\n";
$idd[] = $row['idwebsiteprimary'];
foreach ($resultset2 as $row2) { // Foreach sets it's pointer to the beginning every time, so this should work
echo "test";
if ($idd[$url]==$row2['idwebsite']) {
echo "<li class=\"s01\"><a href=\"a\"><span>". $row2['name'] ."</span></a></li>\n";
}
}
echo "</ul>\n";
}
Alternatively, you can reset the internal pointer of $result2
on each iteration of the first loop by calling mysql_data_seek($result2, 0);
like this:
while ($row = mysql_fetch_array($result)) {
echo "<li class=\"s01\"><a class=\"s03\" href=" . $row['link'] . "><span>". $row['onomaselidas'] ."</span></a>\n";
echo "<ul class=\"pn2\">\n";
$idd[] = $row['idwebsiteprimary'];
mysql_data_seek($result2, 0);
while ($row2 = mysql_fetch_array($result2)) {
echo "test";
if($idd[$url]==$row2['idwebsite']) {
echo "<li class=\"s01\"><a href=\"a\"><span>". $row2['name'] ."</span></a></li>\n";
}
}
echo "</ul>\n";
}