I need some help. I am attempting to pull a few bits of information from two tables within the same database.
I want to pull the user_id from activity_points and match it with user_id from user. When it has matched them I want it to display the full_name for that user.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
$db_host = "localhost";
$db_username = "******";
$db_pass = "*********";
$db_name = "******";
mysql_connect("$db_host","$db_username","$db_pass") or die(mysql_error());
mysql_select_db("$db_name") or die("no database by that name");
?>
<?php
$staticList = "";
$sql = mysql_query("SELECT * FROM phpfox_user_activity WHERE activity_points ORDER BY activity_points DESC LIMIT 10");
$sql2 = mysql_query("SELECT * FROM phpfox_user");
$peopleCount = mysql_num_rows($sql); // count the output amount
if ($peopleCount > 1) {
while($row = mysql_fetch_array($sql)){
$user_id = $row["user_id"];
$activity_points= $row["activity_points"];
$activity_total= $row["activity_total"];
//$user_id = $user_id = $full_name
$account = mysql_num_rows($sql2); // count the output amount
if ($account > 0) {
while($row = mysql_fetch_array($sql2)){
$user_id1 = $row["user_id"];
$full_name = $row["full_name"];
}
if ($user_id == $user_id1){
$staticList .= '<table width="100%" border="1" cellspacing="0" cellpadding="6">
<tr>
<td width="17%" valign="top">' . $full_name . '</td>
<td width="83%" valign="top">' . $activity_points . '<br /></td>
</tr>
</table>';
}
else{
echo "No Dice";
}
}
}
}
?>
</head>
<body>
<?php echo $staticList; ?>
</body>
</html>
Thank you!