Log in

View Full Version : Populating Array....



bunker
11-26-2008, 04:42 PM
Hi all,

First post, Hope I can explain myself and also recive a quick response.

My website has categories and subcategories, for example News is Cat1 Subcat0, Sport-News is Cat1 Subcat1, Travel-News is Cat 1 Subcat2, Restaurants is Cat2 Subcat0, Italian-Restaurants is Cat2 Subcat1, etc...

In the Mysql DB there is a field called url_modrewrite, that I want to fetch. Ive figuered out how to fetch and populate an array only looking at the Category, but not both the Category and the Subcategory...



$sql = mysql_query("SELECT url_modrewrite, cat, subcat FROM content WHERE port = '$port' AND lang = '$lang' AND ubic_menu LIKE '%sup%' ");
$data = array();
//populate array with modrewrites
while($d = mysql_fetch_array($sql)){
$data[$d['cat']] = $d['url_modrewrite'];
}

After I want to printf the value of url_modrewrite: print_r($data[1]);

How could I change the code so I also control the Subcategories!¿

Muchas muchas Gracias x adelantado ( Something like thx in advanced )