View Full Version : Loop doesn't seem to be working for me in my AWS script
RockNRollPig
02-14-2004, 09:28 AM
In this:
$ArraySearchString = array(
497024 => "Web Development",
229614 => "Graphics",
497022 => "Video & Music"
);I'm trying to use a loop to eacho the node and name from my database and have tried doing it like so:
$ArraySearchString = array(
while($row = mysql_fetch_array($result1)){
echo($row['amazonid'] =>."".$row['name'].",");
}
);But I get a parse error on this row:
while($row = mysql_fetch_array($result1)){Anyd ideas?
GCT13
02-14-2004, 09:58 AM
You don't need those mysql functions, your BrowseNodes are stored in an array, not in a database.
Echo the array like this:
foreach($ArraySearchString as $key => $value){
echo $key. ', ' .$value;
}
RockNRollPig
02-14-2004, 10:01 AM
That's what I'm saying...i'm trying to populate the array with the correct nodes and category titles. And my database has the nodes and category titles.
GCT13
02-14-2004, 10:14 AM
If your data is stored in the database, you don't need to re-create the $ArraySearchString array.
RockNRollPig
02-14-2004, 10:18 AM
Hmm...well I'm using the tutorial you wrote...so in aws-functions.php...what goes in $ArraySearchString?
$ArraySearchString = array(
#what goes here#
);
MattM
02-14-2004, 10:24 AM
I'm storing the nodes in a database and I don't have anything under $ArraySearchString. You won't need it unless you want to echo that variable instead of the database.
RockNRollPig
02-14-2004, 10:29 AM
Originally posted by MattM
I'm storing the nodes in a database and I don't have anything under $ArraySearchString. You won't need it unless you want to echo that variable instead of the database. Well...for instance, in browse.php this code:
if(!isset($ArraySearchString[$Browse])){ i'm assumign i just need to remove that?
GCT13
02-14-2004, 10:38 AM
In the tutorial I used an array to store the BrowseNode info for a handful of reasons. If your BrowseNode info is stored in a database then you'll have to find each instance of $ArraySearchString and update it to pull the data from the database instead.
RockNRollPig
02-14-2004, 10:40 AM
Ah...ok...
MattM
02-14-2004, 10:42 AM
I didn't explain correctly on my part - I updated it to pull the data from the database instead.
RockNRollPig
02-14-2004, 10:49 AM
Originally posted by MattM
I didn't explain correctly on my part - I updated it to pull the data from the database instead. That's what I've been trying to do from the start...and it wasn't working. Are you saying you updated $ArraySearchString to pull it's info from the database? If so...how?
GCT13
02-14-2004, 10:56 AM
AutomatikStudios, if you don't have a lot of BrowseNodes you may want to use the array setup for now for whatevery site you're working on. That'll give you time to work on the database setup.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.