goldd1gger
12-05-2007, 07:07 PM
I have the following example of array, what I want to do it have it be store in a database and then retrieve it using "for loop" statement. How to do that?
I know how to get the $mode array, but how to programmed the $transport array in php.
code for $mode array:
$sql = "select distinct model from tblcar order by car_di";
$rssql= DBUtils::runQuery($sql,$dbhandle); --> this execute the query
$mode = array();
while ($rsdata = mysql_fetch_assoc($rssql)) {
$mode[] = $rsdata['model'];}
Array Example:
$mode = array('air','water','land');
$transports = array(
'air'=>array('plane','helicopter','air-baloon'),
'water'=>array('boat','watersky','submarine'),
'land'=>array('motorcycle','car')
);
$brands = array(
'plane'=>array('Boeing707', 'F-16', 'Columbia'),
'helicopter'=>array('BayWatch Heli', 'Police Heli'),
'air-baloon'=>array('Zeppelin'),
'boat'=>array('Baywatch Safeguard Boat', 'JetBoat'),
'watersky'=>array('JetSky','Board-Sky'),
'submarine'=>array('K-19'),
'motorcycle'=>array("Yamaha", "Harley Davidson", "Ducati"),
'car'=>array("Hummer", "Renault", "Porsche")
);
I know how to get the $mode array, but how to programmed the $transport array in php.
code for $mode array:
$sql = "select distinct model from tblcar order by car_di";
$rssql= DBUtils::runQuery($sql,$dbhandle); --> this execute the query
$mode = array();
while ($rsdata = mysql_fetch_assoc($rssql)) {
$mode[] = $rsdata['model'];}
Array Example:
$mode = array('air','water','land');
$transports = array(
'air'=>array('plane','helicopter','air-baloon'),
'water'=>array('boat','watersky','submarine'),
'land'=>array('motorcycle','car')
);
$brands = array(
'plane'=>array('Boeing707', 'F-16', 'Columbia'),
'helicopter'=>array('BayWatch Heli', 'Police Heli'),
'air-baloon'=>array('Zeppelin'),
'boat'=>array('Baywatch Safeguard Boat', 'JetBoat'),
'watersky'=>array('JetSky','Board-Sky'),
'submarine'=>array('K-19'),
'motorcycle'=>array("Yamaha", "Harley Davidson", "Ducati"),
'car'=>array("Hummer", "Renault", "Porsche")
);