Hi everyone;
I have finally given up trying to get this REALLY simple peice of code to work. I have litterly been tearing my hair out but this is sooo simple; I really must be overlooking something.
The idea is to form relationships between people via 2 tables (Which I have working).
Users table with ALL users Information and another table for friendship-links.
ID = you
FriendID = the friend.
So; if your ID = 1 and FriendID = 4 AND status = 1; you can view the profile information and display a little tick box in the search tools.
But if status = 4 or empty; it displays a little cross and “Unban” or “invite”.
Here is the code;
PLEASE, for the love of god someone help me.
<?php
$settingsSql = mysql_query("SELECT * FROM users WHERE id='$_SESSION[user_id]'");
while ($settings = mysql_fetch_array($settingsSql)) {
$country = $settings['country'];
$town = $settings['town'];
$sex = $settings['sex'];
$available = $settings["availability"];
$matchSql = mysql_query("SELECT * FROM users WHERE country='$country'");
while ($match = mysql_fetch_array($matchSql)) {
$FriendID = $match['id'];
echo "<tr>";
echo "<td><img src='".$match['imagelocation']."' width='25px' height='25px'></td>";
if ($match["availability"] == '1') {
echo "<td><img src=\"images/tick.png\" width=\"12px\" height=\"12px\" title=\"Available\"></td>";
} else {
echo "<td><img src=\"images/cross.png\" width=\"12px\" height=\"12px\" title=\"Not Available\"></td>"; }
echo "<td><a href=\"popup.details.php?id=".$FriendID."\" onclick=\"window.open('popup.details.php?id=".$FriendID."','popup','width=300,height=300,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=50,top=0'); return false\">".$match['user_name']."</a></td>";
echo "<td>".$match['town']."</td>";
echo "<td>".$match['sex']."</td>";
echo "<td>SPORTS</td>";
echo "<td>".$match['nationality']."</td>";
echo "<td>";
echo "<select name=\"select\" id=\"select\">";
$GetListSQL = mysql_query("SELECT * FROM users_list WHERE user_id = '$_SESSION[user_id]'");
while ($GetList = mysql_fetch_array($GetListSQL)) {
echo "<option value=\"".$GetList['list_id']."\">".$GetList['title']."</option>";
}
echo "</select>";
echo "</td>";
[b]$CheckListSQL = mysql_query("SELECT * FROM users_friends WHERE user_id = '$_SESSION[user_id]'");
while ($CheckList = mysql_fetch_array($CheckListSQL)) {
if ($CheckList['friend_id'] === $FriendID) {
echo "<td><img src=\"images/tick.png\" width=\"12px\" height=\"12px\" title=\"Already Friends\"></td>";
}
if (empty($CheckListSQL)) {
echo "<td><img src=\"images/cross.png\" width=\"12px\" height=\"12px\" title=\"Not Friends\"></td>";
}
}[/b]
echo "<td><form><a href='new_message.php?message_to=". $match['id'] ."'><img src='images/message.png' width='25' height='25' /></a></form></td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"10\"><hr /></td>";
echo "</tr>";
}
}
?>
I have highlighted the issue section. This is the first stage of code I came up with. Right now; the code is long and messy so I want to keep it as Simple as possible.
“Less is more”; so the less code there is, the better it will be.
Kind regards and a thanks if you can help me out.