crazy sarah crazy sarah - 1 year ago 77
HTML Question

serializing the POST array to be able to pass lots of data through a link

I'm having a noobie problem getting my head round how I can make this work.

I have a page listing products from my DB. On that page there is a filter form which POSTs lots of data to refine the product listing, ie how many results per-page, sort order, pricefrom, priceto plus an array of subcategories

I also have a paging system which is just the standard zencart (

incase anyone is familiar) paging system which shows links for the next, previous and some page numbers. Normally it would pass params as
at the end of the links but I have all these fancy filters I've made.

My idea is to serialize the
array and send it as a
param in the links:

<a href="index.php&arr=<?php echo serialize($_POST[]);?>">nxt</a>

but is this seems bad all the serializing and unserializing.

What's the best way of doing this?

I can't figure it out!

Answer Source

You can remove the [] and urlencode() the serialized data:

<a href="index.php&arr=<?php echo urlencode(serialize($_POST));?>">nxt</a>

But you better use sessions. See the manual.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download