This is a repost. I've got a couple of problems that I can't quite figure out.
First, the search result spits out the same individual spits out the same person 3-4 times each. I do have a "join" condition (clients.cusername = interests.cusername) but that hasn't solved my problem
Second, I want each persons name to be a link and pass their cusername to the next page. I have the following coding for this:
<a href=\"userprofile.php?CUserName=$row->CUserName\">$row->CFirstName $row->CLastName</a>
When you put your mouse over the link, it doesn't show username it is going to pass.
Anyway, here's my code below:
<?PHP
//query for matches
$query = "SELECT clients.cusername, CFirstName,CLastName,CEmail,CCity
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
";
$answer = mysql_query($query);
$total_rows = mysql_num_rows($answer);
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 bgcolor=\"#dddddd\"><B>#</b></td>";
print "<TD bgcolor=\"#dddddd\"><B>Name</b></td>";
print "<TD bgcolor=\"#dddddd\"><B>Email</b></td>";
print "<TD bgcolor=\"#dddddd\"><B>City</b></td>";
print "<TD bgcolor=\"#dddddd\">
<a href=\"faqbuddylist\" target=\"new_window\"><B>Buddy list</b></a>
</td>";
print "</tr>";
for ($loopvar=0; $loopvar<$total_rows; $loopvar++)
{
//This queries others with the same interests
$row = mysql_fetch_object($answer);
$tempvar = $loopvar+1;
print "<tr>";
print " <TD>$tempvar</td>
<TD><a href=\"userprofile.php?CUserName=$row->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?CUserName=$row->CUserName\">Add to my buddy list</a></b>
</font>
</td>";
print "</tr>";
}
print "</table>";
print "<BR><BR>";
?>