Re: Holding an array in a session

From: Date: Fri, 19 Nov 2004 10:51:14 +0000
Subject: Re: Holding an array in a session
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-202498@lists.php.net to get a copy of this message
Shaun wrote:
Hi, I have created an array of tables in my database and put it into a session using the following code: $_SESSION['ses_csv_files'][] = array();
$_SESSION['ses_csv_files'] = array(); // without []
$qid = mysql_query("SHOW TABLES"); $num = mysql_num_rows($qid); for ($i = 0; $i < $num; $i++) { $r = mysql_fetch_array($qid); $_SESSION['ses_csv_files'][$i] = $r[0]; }
$qid = mysql_query("SHOW TABLES"); while ( $r = mysql_fetch_assoc( $qid ) ) {
    $_SESSION['ses_csv_files'][] = $r[0];
}
I would like to be able to print the current value of the session on various pages in my application, however I can only find reference to looping through an array in one go. I know I can use next() to increment the pointer in the array, is it possible for the session to hold the current pointer in the array, if so how can I display its value?#
$_SESSION['key'] = $current_array_key; // f.e. 0 on the first page echo $_SESSION['ses_csv_files'][$_SESSION['key']]; -- Sebastian Mendel www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet

« previous php.general (#202498) next »