I'm in need of a bit of help with linking in PHP. The problem I have for both is quite similar. They both occur on a search results page. First problem is, I want people to be able to click on a name and view their profile. However, when I move my mouse over their name, the CUserName variable isn't changing. It stays the same username for all the links.
The other problem is i've created a "buddy list" where I want people to be able to click on the link and that profile would be saved in their private buddy list. Again, with the link, when I move the cursor over, this time, the CID doesn't display at all. Both problems are coded exactly the same but have different problems....what's up with that?
I've included my coding below and thanks for your help:
<?PHP
session_start();
include("dblib.inc");
include("dynamicmenu.inc");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>Search results</title>
<Link href="arial.css" rel=stylesheet title=arial type=text/css>
<body>
<BR>
<img src="pics/logo.gif"><BR>
<BR>
<?PHP
//query for matches
$query = "SELECT CFirstName,CLastName,CEmail,CCity, CID
FROM clients,interests
WHERE
((I1 = '$Interests' OR I2 = '$Interests' OR I3 = '$Interests' OR I4 = '$Interests' OR I5 = '$Interests' OR I6 = '$Interests' OR I7 = '$Interests')
OR (CCity LIKE '$C%%%%%%%%%%%%%%%%%%%%%'
OR CPicture LIKE '$C%%%'
OR CEyeColor LIKE '$C%%%%%%%%%%%%%%%%%%%%%'
OR CHairColor LIKE '$C%%%%%%%%%%%%%%%%%%%%%'
OR CKids LIKE '$C%%%%%%%%%%%%%%%%%%%%%'
OR CBody LIKE '$C%%%%%%%%%%%%%%%%%%%%%'
OR CEducation LIKE '$C%%%%%%%%%%%%%%%%%%%%%'
OR CChurch LIKE '$C%%%%%%%%%%%%%%%%%%%%%')
AND clients.cusername = interests.cusername)
ORDER BY CCity, CLastName
";
$result = mysql_query($query);
$total_rows = mysql_num_rows($result);
if($total_rows == 0)
print "<BR><font color=red>Sorry! No profiles matched your search criteria</font><BR>";
else
print "Found <B>$total_rows profiles</b> that matched your search criteria.<BR><BR>";
//Prints out the results of your query
print "<table border=1 cellpadding=5 cellspacing=0>";
print "<TR>";
print "<TD><B>#</b></td>";
print "<TD><B>Name</b></td>";
print "<TD><B>Email</b></td>";
print "<TD><B>City</b></td>";
print "<TD>Buddy list</td>";
print "<TD>CID</td>";
print "</tr>";
for ($loopvar=0; $loopvar<$total_rows; $loopvar++)
{
//This queries others with the same interests
$row = mysql_fetch_object($result);
$tempvar = $loopvar+1;
print "<tr>";
print " <TD>$tempvar</td>
<TD><a href=\"userprofile.php?CUserName=$CUserName\">$row->CFirstName $row->CLastName</a></td>
<TD><a href=\"mailto:$row->CEmail\">$row->CEmail</a></td>
<TD>$row->CCity</td>
<TD>
<font size=-1>
<B><a href=\"buddyadded.php?CID=$CID\">Add to my buddy list</a></b>
</font>
</td>
<TD>$row->CID</td>";
print "</tr>";
}
print "</table>";
print "<BR><BR>";
//This retrieves the variables from the previous forms
foreach ($HTTP_POST_VARS as $key=>$val)
if (gettype($val) == "array")
{
print "";
foreach ($val as $two_dim_value)
print "";
}
else
{
print "";
}
?>
<BR>
<B><a href="memberprofile.php?<?=$PHPSESSID; ?>">Back to home</a></b><BR>
<BR>
</body>