Hi
In my database table I have a column called ID that has individual numbers for each of my users. The next column is called ReferringuserID. Lets say user 2 has an ID of 2 and has referred user 5, 6 and 7. So in the ReferringuserID column of 5, 6 and 7, it will hold the number 2. Another column of my table is user-email. I want to get the email address of user 5, 6 and 7 because the number 2 is present in the ReferringuserID of user 5, 6 and 7.
This is what I been trying to use but this code only gives me the first email address (user 5). How can I get all the email addresses?
function get_email($id='')
{
if ($id!=null)
{
global $db;
$query = "SELECT * FROM $db->users WHERE ReferringuserID = ".$id."";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
return $row['user-email'];
}
}
}