RE: [PHP] POST-ing or GET-ing an array
| From: | Ford, Mike [LSS] | Date: | Wed, 30 Oct 2002 11:39:26 +0000 |
| Subject: | RE: [PHP] POST-ing or GET-ing an array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-122005@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Paul Nicholson [mailto:paul@dtnicholson.com]
> Sent: 29 October 2002 19:10
> To: Sascha Cunz; Petre Agenbag; php-general@lists.php.net
>
> Hey,
> I think you should be able to serialize and urlencode the
> array and then
> pass that via get/post.....post would be a lot better as get
> is limited to so many chars.
> Something like:
> $sql = "select stuff from my_table";
> $result = mysql_query($sql);
> while ($myrow = mysql_fetch_assoc($result)) {
> $id = $myrow["id"];
> $my_array[] = $id;
> }
> echo '<a href="next_page.php?array='.
> urlencode(serialize($my_array)) .'">Next</a>';
> You'll need to unserialize+urldecode the array at the other end.
You shouldn't need to urldecode(), as this happens automatically. In fact, this is exactly
*why* you need to urlencode() it in the first place!
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211