Re: Holding an array in a session

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux