[thelist] site critique please
Simon Coggins
ppxsjc1 at nottingham.ac.uk
Tue Sep 25 10:50:24 CDT 2001
> Except that this case was in context of placing the onclick in the TD, not
> the anchor. Thusly, "this" would not contain an href.
*slaps forehead*
Yes, of course, you're right. Hmm, I probably owe a tip:
A while ago there was some talk about sending arrays via forms using
PHP. Here's an alternative approach that doesn't rely on converting the
array to a delimited string:
<tip type="PHP" author="Simon Coggins">
You can use the serialize() function to pass arrays via hidden form fields
in PHP.
On the first page do this:
<?php
$fruit=array("apples","bananas","oranges","plums");
$friut=serialize($fruit);
$fruit=urlencode($fruit);
?>
<form action="form2.php" method="post">
<input type="hidden" name="fruit" value="<?php=$fruit?>">
<input type="submit">
</form>
Then on the second page include this:
<?php
$fruit=$HTTP_POST_VARS["fruit"];
$fruit=urldecode($fruit);
$fruit=unserialize($fruit);
print "<pre>\n";
print_r($fruit);
print "</pre>\n";
?>
You should get the original array back unchanged.
</tip>
Simon
More information about the thelist
mailing list