Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL get info from 2 tables and compare
    text
    copied!<p>I have 2 tables that I want to compare and find the users that the username is not following and then display the username of the person not being followed.</p> <pre><code>Edit: Table 1: users username Table 2: follow username (the name of the user) followname (the name of the person the user follows) In Table 2 username and followname are never null. When a user follows another user then it is put into the list like so: Username Followname derekshull dvdowns derekshull testuser dvdowns testuser testuser 1511project derekshull newuser </code></pre> <p>In my head I see table 1 getting a list of all the usernames (column name is "username" from table 1) and then gets a list of all the usernames the user ($username) is not following (column name is "followname" from table 2).</p> <p>How do I make it compare the two lists and not display the usernames the user is following already?</p> <p>Here's what I have right now. For some reason it is displaying users that I follow and don't follow.</p> <pre><code>$alluserslookup = mysql_query("SELECT * FROM users WHERE username!='$username'"); $thefollowerslookup = mysql_query("SELECT * FROM follow WHERE username='$username'"); while ($followersrow = mysql_fetch_assoc($thefollowerslookup)) { $afollower = $followersrow['followname']; while ($allusersrow = mysql_fetch_assoc($alluserslookup)) { $allusers = $allusersrow['username']; if ($afollower != $allusers) { echo "&lt;a href='viewprofile.php?viewusername=$allusers'&gt;$allusers&lt;/a&gt;&lt;br&gt;"; } } } </code></pre>
 

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