oracle259 Posted September 25, 2006 Share Posted September 25, 2006 How do i create an array from a mysql result. So far i have tried thiswhile ($res = mysql_fetch_array($result, MYSQL_BOTH) {$link[] = $res[item];}echo $link[];but that doesnt seem to work.any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/22021-create-array-from-mysql-result/ Share on other sites More sharing options...
Barand Posted September 25, 2006 Share Posted September 25, 2006 instead of echo $link, you need to loop thru the array[code]foreach ($link as $item) echo $item.'<br/>';[/code] Link to comment https://forums.phpfreaks.com/topic/22021-create-array-from-mysql-result/#findComment-98484 Share on other sites More sharing options...
Gaoshan Posted September 26, 2006 Share Posted September 26, 2006 The array is created automatically by mysql_fetch_array. To step through that array just use:[code]while ($row = mysql_fetch_array($result)) { echo $row[0], $row[1], $row[2]; }[/code] Link to comment https://forums.phpfreaks.com/topic/22021-create-array-from-mysql-result/#findComment-98669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.