Page 1 of 1

mysql_fetch_array

Posted: Sat Oct 02, 2004 2:46 am
by billybonz81
Is there a way to put the results of mysql_fetch_array into a session?
ex:

$sql = "SELECT ID FROM DATA";
while ($row = mysql_fetch_array($sql)) {
echo $row['id'] //i need all of the results for this in a session
}
not sure how much sense that makes, but maybe someone here understands me

Posted: Sat Oct 02, 2004 2:57 am
by denlou
Like this??

Code: Select all

<?php
session_start();
$sql = "SELECT id FROM date";
while ($row = mysql_fetch_array($sql))
{
    $_SESSION[$row[id]] = $row[id];
}
?>
I have no easy way to execute this script, but try that.

Posted: Sat Oct 02, 2004 3:01 am
by feyd
I'd store it into a single array inside the session..

Code: Select all

$_SESSION['fetch'] = array();
while($row = mysql_fetch_assoc($results)) $_SESSION['fetch'][] = $row['id'];