Re: array data
| From: | Richard Davey | Date: | Wed, 11 Feb 2004 09:22:41 +0000 |
| Subject: | Re: array data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177358@lists.php.net to get a copy of this message | ||
Hello Imran,
Wednesday, February 11, 2004, 8:17:11 PM, you wrote:
IA> Is not working, is it correct way????
IA> File1.php
IA> <? $colors =
IA> array('red','blue','green','yellow'); ?>
IA> <form action="file2.php" method="post">
IA> <input type="hidden" type" name="colors"
IA> value="<?=$colors?>">
IA> </fomr>
You can't do it like this. Rather, do the following:
<form action="whatever.php" method="post">
<input type="hidden" name="colors[]" value="red">
<input type="hidden" name="colors[]" value="blue">
<input type="hidden" name="colors[]" value="green">
Or if you prefer you can use some PHP code to write out the input tags
based on a colors array:
<?
$colors = array('red','blue','green','yellow');
foreach ($colors as $color)
{
echo "<input type=hidden name=colors[] value=\"$color\">";
}
?>
--
Best regards,
Richard mailto:rich@launchcode.co.uk