I have read some tutorials on JOINING tables using mysql , but am still very confused.
What im trying to do is , i have a table called shocc_active , it stores information about active users on my website.
In another table shocc_users , i store user information.
Im trying to build a "Who's Online" Page .. i could call all the data from shocc_active , but the only thing stored in their is the username , and the time,
Id like to get other details about the users online from shocc_users , so that i can supply other details in my whos online page such as City , State , and Age , And Gender.
is thiss possible? , I tried using
$sql = "SELECT `city`,`state` from `shocc_users` join on `shocc_active` using username";
But got an error stating
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'on shocc_active using username' at line 1
And ... can i use mysql fetch array with this?
Very lost , please help. And yes , i have google'd and read tutorials im just very confused still.
ive even tried this , and it produces more error
$sql = "SELECT `city`, `state`, `username` FROM shocc_users,
shocc_active WHERE shocc_users.username = shocc_active.username";
$query = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($query) <> 0) {
while($row = mysql_fetch_array($query)) {
echo $row['city'];
}
}