mysql_fetch_array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
billybonz81
Forum Newbie
Posts: 3
Joined: Sat Oct 02, 2004 2:43 am
Location: baytown, tx

mysql_fetch_array

Post 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
denlou
Forum Newbie
Posts: 17
Joined: Fri Sep 24, 2004 7:11 pm
Location: Richmond/Vancouver, BC
Contact:

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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'];
Post Reply