lting
10-21-2004, 01:21 AM
$data = array('1', '2', '3');
foreach($data as $key){
echo $key;
}
this give me result 1,2,3
i got one table (items) in database with one column ('itemid') and there are 4 results inside the table (1,2,3,4)
i want to use foreach to display the results in my database.. so i do
$query = select itemid from items;
$result = mysql_query($query);
$array = mysql_fetch_array($result);
foreach($array as $data){
echo $data;
}
why it is not working? cos $array is an array already? can anyone guide me here :( sorry newbie here
foreach($data as $key){
echo $key;
}
this give me result 1,2,3
i got one table (items) in database with one column ('itemid') and there are 4 results inside the table (1,2,3,4)
i want to use foreach to display the results in my database.. so i do
$query = select itemid from items;
$result = mysql_query($query);
$array = mysql_fetch_array($result);
foreach($array as $data){
echo $data;
}
why it is not working? cos $array is an array already? can anyone guide me here :( sorry newbie here