PDA

View Full Version : Finding Referers


1Unreal
07-16-2009, 10:43 PM
Im trying to make something which will show what users a user has refered to the site. Im using this code to do it.

$query = $db->query_read("SELECT `username` FROM `user` WHERE `referrerid` = $id");
$results = $db->fetch_array($query);

ob_start();
print_r($results);
$referers = ob_get_contents();
ob_end_clean();

The problem is that this only fetches 1 result. I need to get them all.

Dismounted
07-17-2009, 06:04 AM
Place the fetch_array() call into a while loop. Examples can be found in most vBulletin files.

1Unreal
07-17-2009, 06:37 AM
Thank you.

This is my final code if anyone else was curious

$query = $db->query_read("SELECT `username` FROM `user` WHERE `referrerid` = $id");
while($results = $db->fetch_array($query)){
$referers .= $results[username];
}