General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Iron Speed
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old July 8th, 2002, 12:58 PM
hereford hereford is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 11 hereford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hereford
Angry Array/Loop/Print problems

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'>&nbsp;");
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'>&nbsp;");
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

Reply With Quote
  #2  
Old July 8th, 2002, 02:33 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Hereford,

What was the problem?
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old July 8th, 2002, 02:34 PM
hereford hereford is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 11 hereford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hereford
Cool Nevermind

I got it everyone.

Reply With Quote
  #4  
Old July 11th, 2002, 08:55 AM
hereford hereford is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 11 hereford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hereford
The problem was...

The problem was with my mysql statement. The two that said :
$a = mysql_query("select Outdoor_Activity from neighbors_1 where location='$where'");
$d = mysql_query("select Outdoor_Activity from neighbors_1 WHERE E_mail='$visitor'");
The first one needed to be changed to WHERE E_mail ='$email'
and the second needed to be WHERE E_mail='$myrow[3]'

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Array/Loop/Print problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway