Hey everyone. Ok so I need some help debugging this code. What I want this code to do is search the location column of a table and pick all the ones that match up to you (the user browsing the page). After that I would like it to go to the column Outoodr_Activity and print out all the activities that match up to you (same as above). Now, here is the problem. Instead of printing the other users outdoor activities, it is printing mine in their spot. It is also repeating it 3 different times. I think this is a loop problem, but I really dont know. Here is the code.
PLEASE email me if you post
Code:
<?
//first check that the cookie exists.
if ($visitor){
mysql_connect("localhost", "tawanda", "anusha1")
or DIE("Unable to connect to database");
@mysql_select_db("eneighbors_db") or die("Unable to select database");
$result = mysql_query("select * from neighbors_1 where E_mail='$visitor'");
//next, use myrow to print out all ready existing information. This is done using
//the printf function embedded in the html.
$myrow = mysql_fetch_row($result);
$where = $myrow[43];
$outdoor = $myrow[31];
$resout = mysql_query("SELECT * FROM neighbors_1 WHERE First_Name !=''");
echo "<hr>
Similar Outdoor Activities
<table border= 0 cellspacing = 0 width = 97%>\n";
echo "<tr><td height='21' width='150' valign='top' bgcolor='#0000CC'><b><font size='2' color='white'>Name</font></b></td><td width='200' valign='top' bgcolor='#0000CC'><b><font size='2' color='white'>Email Address</font></b></td><td width='180' valign='top' bgcolor='#0000CC'><b><font size='2' color='white'>Outdoor Activities</font></b></td><td valign='top' width='120' bgcolor='#0000CC'><b><font size='2' color='white'>Phone Number</font></b></td></tr>\n";
if ($myrow = mysql_fetch_row($resout)){
do{
if(($myrow[43] == $where)){
$x++;
if (($x % 2) == 1){
$bg='#A8BDF4';
}
else{
$bg='#FFFFFF';
}
print("<tr><td bgcolor='$bg'><font size='2'> ");
printf("<a href=\"personal.php?Customer_ID=%s\"> %s %s</a></font>", $myrow[0],$myrow[1],$myrow[2]);
print("</td><td bgcolor='$bg'><font size='2'>");
printf("<a href=\"mailto:%s\">%s", $myrow[3],$myrow[3]);
print("</a></font></td>");
printf("<td bgcolor='$bg'><font size='2'>");
$a = mysql_query("select Outdoor_Activity from neighbors_1 where location='$where'");
while($b = mysql_fetch_array($a)){
$c = explode(",", $b[0]);
$d = mysql_query("select Outdoor_Activity from neighbors_1 WHERE E_mail='$visitor'");
while($e = mysql_fetch_array($d)){
$f = explode(",", $e[0]);
foreach ($f as $value){
if (in_array($value, $c)){
echo "$value<br>";}
}
}
}
print("</font></td>");
print("<td bgcolor='$bg'><font size='2'> ");
printf("%s",$myrow[10]);
print("</font></td>");
} else {echo "";}
} while ($myrow = mysql_fetch_row($resout));
} else { echo "";
}
echo "</table>\n";
}
else {
header('Location: http://e-neighbors.mit.edu/neighborhood/index.php');
}
?>
-Patrick