I have a table in mysql called "shocc_active" it keeps track of who is actively on mysite. After they login , it places the username , time and IP of the user into the shocc_active table.
Im trying to build a list of who's online , a php page
In the list im trying to have other details from the shocc_users table , which stores the user's info , such as city , state , ect ...
I have read and found that a join is the best way to do this? although im not having very much success.
The username coloum in shocc_active and the username colum in shocc_users are the relationship.
<?
require_once('./system/config.php');
$sql = "SELECT `username`,`age`,`city`,`state` FROM `shocc_users` JOIN shocc_active on shocc_users.username = shocc_active.username";
$query = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($query) <> 0) {
while($array = mysql_fetch_array($query)) {
echo $array['username'];
echo $array['age'];
echo $array['state'];
echo $array['city'];
}
}
?>
That doesnt yeild me any results , only generating an error from MYSQL saying that the field "username" is ambigious?
Am i doing the query wron?G is this not the right way to go?
Trying to pull data from shocc_users , from each user who is in shocc_active
Thanks for any help