sstaubin01 — 2001-01-29T16:49:38-05:00 — #1
I'm creating a array in php on one page and want to pass all occurances of the array to another page using the <a> tag. Can someone tell me how to do this. Thanks.
karl — 2001-01-29T16:59:24-05:00 — #2
$data = serialize( $array );
echo "<a href='/page.php?data=$data'>Go To Page</a>";
then to get the info back use:
$array = unserialize( $data );
freddydoesphp — 2001-01-29T18:17:17-05:00 — #3
Don't think that is gonna work you mave to use a from and make a hidden input and then submit the form somehow.
karl — 2001-01-29T19:17:05-05:00 — #4
True, it does depend on the aray not storing huge amounts of data. The other option is to use PHPs session functions and store the serilized array in a session variable.
freddydoesphp — 2001-01-29T19:18:24-05:00 — #5
I tried the serialize() aproach but the serialized string contains more than one character that the browser does not like in a query string, I think sessions would be the best way to go
sstaubin01 — 2001-01-30T10:34:28-05:00 — #6
I thought I would be able to reference all occurances of an array and be able to pass that variable. Mabye I should make the call again on the new page. I was just trying to avoid the call since I already had the information from a call in the first page.
Sorry I took so long to respond. I tried using serialize last night and it didn't work as Freddy stated.
I started looking into Sessions and it seems complex, more complex than what i'm trying to accomplish here.
skunk — 2001-01-30T11:08:23-05:00 — #7
Sessions aren't that complex really, and if you figure out how to do them you'll find loads of usedul applications. The only downside is that session data won't be passed on if your user doesn't have cookies turned on (unless it's possible to extract the session id and pass it in an <a href> tag - that should work theoretically but I've never seen it done...)
Check out these tutorials:
http://www.php.net/manual/en/ref.session.php (PHP Manual)
sstaubin01 — 2001-01-30T12:02:13-05:00 — #8
Thanks Skunk. I'll check out the links.
spaceman — 2001-04-14T04:52:18-04:00 — #9
An alternative to using serialize()/unserialize with sessions is to use implode()/explode(), eg:
Make sure you've got your session set up properly first, of course. My approach might have benefits over serialize() because it seems if you want to serialise(), the you have to worry about urlencode() etc. (see: http://www.php.net/manual/en/function.serialize.php)