Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I had to guess, you want the URLs of the thumbnail links to read something like this:</p> <pre><code>"user_view.php?user_id2=92" "user_view.php?user_id2=93" "user_view.php?user_id2=94" "user_view.php?user_id2=95" </code></pre> <p>but from what I can tell, they're all using the value of the variable $pal_array, which, as far as I can tell looks like this</p> <pre><code>"92,93,94,95" </code></pre> <p>Which would make each and every one of your urls look like this:</p> <pre><code>"user_view.php?user_id2=92,93,94,95" </code></pre> <p><strong>The Fix:</strong> So to fix the immediate problem, you should explode() that list of ids and use those individually instead of the whole list at once. More important, however, is to set up your database correctly.</p> <p><strong>The solution:</strong> Store your list of pals in a separate table, not in a field of the user. Each user has a number of pals. Each pal is another user with their own user Id. What you need is a separate table whose only job is to relate one user's ID to another's. Your two tables might look like this:</p> <pre><code>Table: User user_id int; username varchar; email varchar; thumbnail_url varchar; Table: User_pals pal_1 int; //user_id of the first user pal_2 int; //user_id of pal of first user pals_confirmed bool; //False or 0 until both friends are in agreement </code></pre> <p>In this setup, the table User_pals is just a big 2 column list binding 2 users together (with an extra column to indicate if friendship has been confirmed). To get a given user's list of friends, you would simply do a couple of queries like this:</p> <pre><code>"SELECT pal_2 FROM User_pals WHERE pal_1 = $user_id"; "SELECT pal_1 FROM User_pals WHERE pal_2 = $user_id"; </code></pre> <p>This would give you a nice list of user_ids that were pals of your user. (There are more well designed table structure's than this that would require only one query, but you get the idea).</p> <p>So hopefully this helps get you on the right track. More info can be found <a href="http://www.w3schools.com/sql/sql_join.asp" rel="nofollow" title="w3schools Join tutorial">at w3schools.</a>. Beyond that just googling around for relational database structure and design will be immensely useful.</p>
 

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