Может ли кто-нибудь сказать мне, почему следующий бит кода получает только все изображения в запросе, за исключением последнего?Запрос не получает все mysql_fetch_assocs
$userquery = mysql_query("SELECT * FROM acceptedfriends WHERE profilename='$profilename' ORDER BY RAND() LIMIT 4");
while ($userrun = mysql_fetch_assoc($userquery))
{
$users = $userrun['username'];
$imagequery = mysql_query("SELECT * FROM users2 WHERE username='$users'");
while ($imagefetch = mysql_fetch_assoc($imagequery))
{
$location = $imagefetch['imagelocation'];
$image = "<img src='$location' width='60' height='40'>";
if ($profilename==$username)
{
echo '<div id="hovercolor2" style="width:294px; float:left;"><table><tr> <td>'.$image.'</td><td><div style="margin-bottom:5px;"><a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank">'.$users.'</a></div><div><a href="http://www.pearlsquirrel.com/conversation.php/'.$users.'" style="text-decoration:underline;" target="_blank"><div style="font-size:.7em";>Click to enter a conversation.</div></a></div></td></tr></table></div><div id="hrdiv3" style="float:left; width:298px;"></div>';
}
else
{
echo '<div id="hovercolor2" style="width:294px; float:left;"><table><tr><td>'.$image.'</td><td><a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank">'.$users.'</a></td></tr></table></div><div id="hrdiv3" style="float:left; width:298px;"></div>';
}
}
}
Этот
$image = "<img src='$location' width='60' height='40'>";
не получает последнее изображение в запросе. Я потратил около часа на то, чтобы решить эту проблему и понятия не имею. Любая помощь будет оценена по достоинству.
упрощенный код с той же ошибкой
$userquery = mysql_query("SELECT * FROM acceptedfriends WHERE profilename='$profilename' ORDER BY id DESC LIMIT 6");
while ($userrun = mysql_fetch_assoc($userquery))
{
$users = $userrun['username'];
$location = $userrun['imagelocation'];
$image = "<img src='$location' style='width:60px; height:40px;'>";
if ($profilename==$username)
{
echo '<div id="hovercolor2" style="width:294px; float:left;"><table><tr><td>'.$image.'</td><td><div style="margin-bottom:5px;"><a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank">'.$users.'</a></div><div><a href="http://www.pearlsquirrel.com/conversation.php/'.$pageusers.'" style="text-decoration:underline;" target="_blank"><div style="font-size:.7em";>Click to enter a conversation.</div></a></div></td></tr></table></div><div id="hrdiv3" style="float:left; width:298px;"></div>';
}
else
{
echo '<div id="hovercolor2" style="width:294px; float:left;"><table><tr><td>'.$image.'</td><td><a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank">'.$users.'</a></td></tr></table></div><div id="hrdiv3" style="float:left; width:298px;"></div>';
}
}
Вы не видите последнее изображение? используйте mysql_num_rows(), чтобы получить количество строк, оттуда мы можем продолжить исследование. – Chibuzo
, так что вы получаете только 3 изображения? и by by '$ image =" ";' действительно должно быть '$ image =" ";' :) – davogotland