Hi *
I have spent the last 18 hrs or so trying to get the wright sql code or think of an alternative but I just can't get my head around it. If any one can help me it would be
awsome.
What I am trying to acheive is getting the correct id to echo out in the row variable.
<?php echo $row['id']; ?>
but it has to based on the mysql table row
user_id which is based on the session username so it works off the users table id.
I have two tables one is users the other is contacts. And I have a user_id at the end of the table contacts.
function manage_contacts() {
echo '<div id="manage">';
$sql = '
SELECT
*
FROM
contacts u JOIN users i ON i.id = u.user_id
WHERE
username = "' . mysql_real_escape_string($_SESSION['username']) . '"
';
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($res)):
?>
<div>
<p><b><?php echo $row['fname'] . " "; ?><?php echo $row['lname'] ." - "; ?></b>
<span class="actions"<a href="update-contacts.php?id=<?php echo $row['id']; ?>">Edit</a> |
<a href="?delete=<?php echo $row['id']; ?>">Delete</a></span></p>
<br />
</div>
<?php
endwhile;
echo'</div>';
}
The following is the call method.
<?php $obj->manage_contacts()?>
It all works if I SELECT * FROM contacts, but if i do that it will show up when another
user logs in and I don't want that to happen if any one has any suggestions it would be
greatly apreciated.