Reply to Re: Form Arrays

Your name:

Reply:


Posted by 4sak3n 0ne on 09/04/07 20:37

On Sep 4, 8:00 am, Kevin Davis <kevin.da...@kevincdavis.net> wrote:
> Hello,
>
> I'm a new person when it comes to PHP and I have a quick question.
>
> I would like to create a form that will allow the user to add more
> information using the same form in case they have (similar to various
> employment sites).
>
> What would be the best way of using form arrays for that function?
>
> Thank you,
> Kevin

I would have an input with a name that is translated to an array.
Have some javascript create the additional inputs...

<form action="something.php" method="post">
<input type="text" name="inputbox[]" value="" />
<input type="text" name="inputbox[]" value="" />
</form>

When this is posted, you can use a foreach loop to run through it. If
you use this method, be sure to check for empty values, because once
the form has been created, its added to the array, empty or not.

if(isset($_POST['inputbox'])){
echo "<h2>Output:</h2>";
echo "<ul>\n";
foreach($_POST['inputbox'] as $v){
echo (!empty($v)) ? "<li>{$v}</li>\n" : "";
}
echo "</ul>\n";
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация