Jump to content

Archived

This topic is now archived and is closed to further replies.

oracle259

Create Array from mysql result

Recommended Posts

How do i create an array from a mysql result. So far i have tried this

while ($res = mysql_fetch_array($result, MYSQL_BOTH) {

$link[] = $res[item];

}

echo $link[];

but that doesnt seem to work.

any help would be appreciated.

Share this post


Link to post
Share on other sites
instead of echo $link, you need to loop thru the array
[code]
foreach ($link as $item) echo $item.'<br/>';
[/code]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.