[nycphp-talk] url pass array as parameter
Tim Lieberman
tim_lists at o2group.com
Mon Jun 30 17:39:48 EDT 2008
Passing arrays in a query string is the wrong way to do it. Too many
things can go wrong.
You could try creating a form, and sticking the serialize()d array
value in to a hidden field. Then POST the form to your gallery page.
<?PHP
echo '<form action="gallery.php" method="POST">
<input type="hidden" name="cart" value="' . serialize($cart) . '"/>
<input type="submit" value="Go To Gallery"/>
</form>';
?>
And in gallery.php
<?PHP
$cart = unserialize($_POST['cart']);
?>
HTH
-Tim
On Jun 30, 2008, at 3:32 PM, chad qian wrote:
> Hi,
> I want to pass an unknow array cart[]: to "gallery" page through
> url link:
>
> My url is:gallery.php?final=cart[]
>
> On gallery.php page
> I want to output everything in this array
>
> My code is:
> $finalcart=array();
> $finalcart=$_get['final']
> for(var i=0;i<sizeof($finalcart);i++)
> print finalcart[i];
>
>
> Maybe my code is wrong.I only want to show my need.Can anyone help
> me to correct my code?
>
> Thanks!
>
> chad
>
>
> The other season of giving begins 6/24/08. Check out the i’m
> Talkathon. Check it out!
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080630/cf8a5646/attachment.html>
More information about the talk
mailing list