Page 1 of 1

Seems Simple...Can't Figure It Out!

Posted: Fri Apr 09, 2004 9:24 pm
by PHP_Ryan
Need some help...I have the following code to hopefully populate variables for a javascript array for a category/subcategory dependant select menu (Choose a category, subcategories get populated):
-----------------------------------------------------

Code: Select all

$sql = "SELECT DISTINCT cat, subcat, subcat_id FROM products ORDER BY cat, subcat"; 

$result = mysql_query($sql); 

$last_cat = ""; 
while ($row = mysql_fetch_array($result)) 
{ 
if ($rowї'cat'] !== $last_cat) 
{ 
echo ""{$rowї'cat']}*"\n"; 
$last_cat = $rowї'cat']; 
} 
echo ""results.php?tunedsearch={$rowї'subcat_id']}|{$rowї'subcat']}#" +\n"; 
}
-----------------------------------------------------
I cannot get the ouput to look like this:
-----------------------------------------------------

"Wheels & More*results.php?tunedsearch=aluminumwheels|Aluminum Wheels#" +
"results.php?tunedsearch=plasticwheels|Plastic Wheels#" +
"results.php?tunedsearch=dishwheels|Dish Wheels",
"Nitro Trucks*results.php?tunedsearch=stadiumtrucks|Stadium Trucks#" +
"results.php?tunedsearch=monstertrucks|Monster Trucks#"+
"results.php?tunedsearch=buggies|Buggies",

-----------------------------------------------------
My DB is set up in the following manor:
-----------------------------------------------------

columns: cat, subcat, subcat_id

example row: Wheels & More, Aluminum Wheels, aluminumwheels

-----------------------------------------------------

Any help would be greatly appreciated...thanks in advance,

Ryan

Posted: Sat Apr 10, 2004 2:20 am
by PHP_Ryan
Got it! Disregard the post...