Note that there are some explanatory texts on larger screens.

plurals
  1. POQuery is not getting all mysql_fetch_assocs's
    primarykey
    data
    text
    <p>Could someone tell me why the following bit of code only gets all images in the query except for the last?</p> <pre><code> $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 = "&lt;img src='$location' width='60' height='40'&gt;"; if ($profilename==$username) { echo '&lt;div id="hovercolor2" style="width:294px; float:left;"&gt;&lt;table&gt;&lt;tr&gt; &lt;td&gt;'.$image.'&lt;/td&gt;&lt;td&gt;&lt;div style="margin-bottom:5px;"&gt;&lt;a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank"&gt;'.$users.'&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.pearlsquirrel.com/conversation.php/'.$users.'" style="text-decoration:underline;" target="_blank"&gt;&lt;div style="font-size:.7em";&gt;Click to enter a conversation.&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div id="hrdiv3" style="float:left; width:298px;"&gt;&lt;/div&gt;'; } else { echo '&lt;div id="hovercolor2" style="width:294px; float:left;"&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;'.$image.'&lt;/td&gt;&lt;td&gt;&lt;a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank"&gt;'.$users.'&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div id="hrdiv3" style="float:left; width:298px;"&gt;&lt;/div&gt;'; } } } </code></pre> <p>This </p> <pre><code>$image = "&lt;img src='$location' width='60' height='40'&gt;"; </code></pre> <p>is not getting the last image in the query. I have spend about and hour trying to solve this and have no idea. Any help would be appreciated.</p> <p>Simplified code with the same error</p> <pre><code> $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 = "&lt;img src='$location' style='width:60px; height:40px;'&gt;"; if ($profilename==$username) { echo '&lt;div id="hovercolor2" style="width:294px; float:left;"&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;'.$image.'&lt;/td&gt;&lt;td&gt;&lt;div style="margin-bottom:5px;"&gt;&lt;a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank"&gt;'.$users.'&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.pearlsquirrel.com/conversation.php/'.$pageusers.'" style="text-decoration:underline;" target="_blank"&gt;&lt;div style="font-size:.7em";&gt;Click to enter a conversation.&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div id="hrdiv3" style="float:left; width:298px;"&gt;&lt;/div&gt;'; } else { echo '&lt;div id="hovercolor2" style="width:294px; float:left;"&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;'.$image.'&lt;/td&gt;&lt;td&gt;&lt;a href="http://www.pearlsquirrel.com/'.$users.'" target="_blank"&gt;'.$users.'&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div id="hrdiv3" style="float:left; width:298px;"&gt;&lt;/div&gt;'; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload