Hello everyone! I need help with my user's profile page. Each user has their own id from one table. I also have another table with their profile information. I am having trouble linking one page that has all the users names on it to their individual pages and show that individuals info. For example i want to click user 3 and go to user 3's page (/profile.php?id=3) and see user 3's information along with their picture. Thanks in advance. Here's my profile page:


Code:
<?php require_once('../Connections/Home.php'); ?>
<?php require_once('../Connections/Home.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "/checkout.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "/login.php?login";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_Info = "-1";
if (isset($_SESSION['MM_ID'])) {
  $colname_Info = (get_magic_quotes_gpc()) ? $_SESSION['MM_ID'] : addslashes($_SESSION['MM_ID']);
}
mysql_select_db($database_Home, $Home);
$query_Info = sprintf("SELECT FirstName, LastName, UserName, Password, EMAIL FROM users WHERE ID = '%s'", $colname_Info);
$Info = mysql_query($query_Info, $Home) or die(mysql_error());
$row_Info = mysql_fetch_assoc($Info);
$totalRows_Info = mysql_num_rows($Info);

$colname_Profile = "-1";
if (isset($_SESSION['MM_ID'])) {
  $colname_Profile = $_SESSION['MM_ID'];
}
mysql_select_db($database_Home, $Home);
$query_Profile = sprintf("SELECT DOB, Site, Phone, town, aboutme, photo FROM profile WHERE ID = %s", GetSQLValueString($colname_Profile, "text"));
$Profile = mysql_query($query_Profile, $Home) or die(mysql_error());
$row_Profile = mysql_fetch_assoc($Profile);
$totalRows_Profile = mysql_num_rows($Profile);

/**
 * Delete cookies - the time must be in the past,
 * so just negate what you added when creating the
 * cookie.
 */
if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){
   setcookie("cookname", "", time()-60*60*24*100, "/");
   setcookie("cookpass", "", time()-60*60*24*100, "/");
}

?>
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Site Name | <?php echo $row_Info['FirstName']; ?> <?php echo $row_Info['LastName']; ?>'s Profile </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="/files/mm_health_nutr.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
<!--

//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//---------------   END LOCALIZEABLE   ---------------
//-->
</script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style11 {	font-size: 18px;
	font-weight: bold;
	color: #10AD29;
}
-->
</style>
</head>
<body bgcolor="#F4FFE4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="#D5EDB3">
    <td colspan="3" rowspan="2" bgcolor="#D9FDB3"><img src="/files/topimage2.jpg" alt="Header image" width="382" height="101" border="0" /></td>
    <td height="50" colspan="3" align="center" valign="bottom" nowrap="nowrap" bgcolor="#D9FDB3" id="logo"><div style="position:absolute; left:207px; top:0px; width:541px; height:114px; z-index: 10;">
      <table width="202" height="16" border="0" cellpadding="0" cellspacing="0">
        <tr valign="top">
          <td width="202"><div align="center"><span class="style11"><img src="/images/header.png" alt="" width="541" height="113" align="absmiddle" /></span></div></td>
        </tr>
      </table>
    </div></td>
    <td width="278" bgcolor="#D9FDB3">&nbsp;</td>
  </tr>
  <tr bgcolor="#D5EDB3">
    <td height="51" colspan="3" align="center" valign="top" bgcolor="#D9FDB3" id="tagline">&nbsp;</td>
    <td width="278" bgcolor="#D9FDB3">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="7" bgcolor="#5C743D"><img src="/files/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>
  <tr>
    <td colspan="7" bgcolor="#99CC66" background="/files/mm_dashed_line.gif"><img src="/files/mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>
  <tr bgcolor="#99CC66">
    <td height="20" colspan="7" bgcolor="#C13F00" id="dateformat"><span class="style1">&nbsp;&nbsp;
      <script language="JavaScript" type="text/javascript">
      document.write(TODAY);	</script>
      </span></td>
  </tr>
  <tr>
    <td colspan="7" bgcolor="#99CC66" background="/files/mm_dashed_line.gif"><img src="/files/mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>
  <tr>
    <td colspan="7" bgcolor="#5C743D"><img src="/files/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>
  <tr>
    <td width="165" valign="top" bgcolor="#5C743D"><table border="0" cellspacing="0" cellpadding="0" width="100%" id="navigation">
      <tr>
        <td width="165">&nbsp;</td>
      </tr>
      <tr>
        <td width="165"><a href="/home.php" class="navText">home</a></td>
      </tr>
      <tr>
        <td width="165"><a href="/home/news.php" class="navText">news</a></td>
      </tr>
      <tr>
        <td><a href="/home/newsletter.php" class="navText">newsletter </a></td>
      </tr>
      <tr>
        <td><a href="/home/address.php" class="navText">address book </a></td>
      </tr>
      <tr>
        <td><a href="http://www.blah.com/" target="_blank" class="navText">blah site </a></td>
      </tr>
      <tr>
        <td><a href="/home/account.php" class="navText">account </a></td>
      </tr>
      <tr>
        <td><a href="<?php echo $logoutAction ?>" class="navText">log out </a></td>
      </tr>
    </table>
      <br />
      *<br />
      &nbsp;<br />
      <br />
      <br />
      <br />
      <br />
      <br />
      &nbsp;<br />
      &nbsp;<br />
    </td>
    <td width="50"><img src="/files/mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
    <td colspan="2" valign="top"><img src="/files/mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
      &nbsp;<br />
      &nbsp;<br />
      <table border="0" cellspacing="0" cellpadding="0" width="484">
        <tr>
          <td width="484" class="pageName"><?php echo $row_Info['FirstName']; ?> <?php echo $row_Info['LastName']; ?>'s Profile</td>
        </tr>
        <tr>
          <td class="bodyText"><table width="496" height="274" border="0" cellspacing="5" id="profile">
            <tr>
              <th width="156" height="166" rowspan="7" scope="col">&nbsp;<?php echo $row_Profile['photo']; ?>
			  

<div id='styled_popup' name='styled_popup' style='width: 100%; height: 100%; display:none; position: static; top: 50px; left: 50px; zoom: 1'>
<table width='380' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td></td>
<td><a href='javascript:fadeOutMyPopup();'><img height='23' width='24' src='/images/close.gif' border='0'></a></td>
</tr>
<tr><td colspan='2' style='background: url("/images/flag.jpg") no-repeat; width: 100%; height: 100%;'>
<iframe src="homefiles/upload.php">Your browser does not support this function.</iframe>
</td></tr>
</table>
</div></th>
              <th height="27" scope="col"><input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $_SESSION['MM_ID']; ?>" /></th>
              <th scope="col"><?php if (isset($_SESSION['MM_ID']) && ($_SESSION['MM_ID'])) { ?>
                    <a href="/home/editprofile.php">Edit My Profile</a> 
                    <?php } ?></th>
            </tr>
            <tr>
              <th height="22" class="smallText" scope="col"><div align="right">Name:</div></th>
              <th class="bodyText" scope="col"><strong>&nbsp;<?php echo $row_Info['FirstName']; ?> <?php echo $row_Info['LastName']; ?></strong></th>
            </tr>
            <tr>
              <th height="26" class="smallText" scope="col"><div align="right">DOB:</div></th>
              <th class="bodyText" scope="col"><strong>&nbsp;<?php echo $row_Profile['DOB']; ?></strong></th>
            </tr>
            <tr>
              <th height="21" class="smallText" scope="col"><div align="right">City:</div></th>
              <th class="bodyText" scope="col"><strong>&nbsp;<?php echo $row_Profile['town']; ?></strong></th>
            </tr>
            <tr>
              <th height="20" class="smallText" scope="col"><div align="right">Phone:</div></th>
              <th class="bodyText" scope="col"><strong>&nbsp;<?php echo $row_Profile['Phone']; ?></strong></th>
            </tr>
            <tr>
              <th height="20" class="smallText" scope="col"><div align="right">Website:</div></th>
              <th class="bodyText" scope="col"><strong>&nbsp;<?php echo $row_Profile['Site']; ?></strong></th>
            </tr>
            <tr>
              <th height="44" class="smallText" scope="col"><div align="right">About Me:</div></th>
              <th width="223" rowspan="2" class="bodyText" scope="col"><strong>&nbsp;<?php echo $row_Profile['aboutme']; ?></strong></th>
            </tr>
            <tr>
              <td height="22"></td>
              <td width="111">&nbsp;</td>
            </tr>
            <tr>
              <td height="23">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="22">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="22">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table>
          <p align="center">&nbsp;</p></td>
        </tr>
      </table>
      <br />
      &nbsp;
            <br />
    </td>
    <td width="4"><img src="/files/mm_spacer.gif" alt="" width="40" height="1" border="0" /></td>
    <td width="4" valign="top"><br />
    &nbsp;<br />
    </td>
    <td width="278">&nbsp;</td>
  </tr>
  <tr>
    <td width="165"><div style="position:absolute; left:7px; top:536px; width:150; height:22; z-index: 5;">
      <table width="150" height="22" border="0" cellpadding="0" cellspacing="0">
        <tr valign="top">
          <td><!-- FavIcon -->
            <head>
            <link rel="shortcut icon" href="http://www.mysite.com/faviconb.ico" />
            </head></td>
  </tr>
  </table>
  </div></td>
    <td width="50">&nbsp;</td>
    <td width="188">&nbsp;</td>
    <td width="313">&nbsp;</td>
    <td width="4">&nbsp;</td>
    <td width="4">&nbsp;</td>
    <td width="278">&nbsp;</td>
  </tr>
</table>
<img src="/files/mm_spacer.gif" alt="" width="50" height="1" border="0" />
</body>
</html>
<?php
mysql_free_result($Info);

mysql_free_result($Profile);
?>