Re: Array to $_GET variable

From: Date: Wed, 10 Nov 2004 17:06:26 +0000
Subject: Re: Array to $_GET variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-201700@lists.php.net to get a copy of this message
Mike Smith wrote:
I am trying to cache a database recordset so users can sort, etc without hitting the database everytime. I'm using ADODB to access a MSSQL database. $s = "SELECT id, part, description FROM parts\n"; $r = $db->Execute($s); $parts = array(id=>array(),part=>array(),desc=>array()) while(!$r->EOF){ array_push($parts['id'],$r->fields[0]); array_push($parts['part'],$r->fields[0]); array_push($parts['desc'],$r->fields[0]); $r->MoveNext(); } // print_r($parts) displays array data. Here's what I'm doing: $v = serialize($parts); echo "<a href=\"{$_SERVER['PHP_SELF']}?getvar=$v\">Link</a>\n"; If($_GET['getvar']){ $newvar = unserialize($_GET['getvar']); //This does nothing echo $newvar; print_r($newvar); } Am i missing something very simple?
You did not tell what is the problem, so I only guess - urlencode? Or the recordset exceeds allowed size for query string? (But I've once seen 3 or 4 EULAs in one link on microsofts site :))
Should I make the array a $_SESSION variable, or how do others "cache" a recordset?
I don't as it gives more trouble than help.

« previous php.general (#201700) next »