You are here: Re: Processing data from multiple multi-line textareas into a multi-dimensional array « PHP Programming Language « IT news, forums, messages
Re: Processing data from multiple multi-line textareas into a multi-dimensional array

Posted by Jeff on 03/20/07 23:23

On Mar 20, 3:00 pm, "phpCodeHead" <phpcodeh...@gmail.com> wrote:
> I know that this sounds like something overly complex - because it is.
> However, if I can keep the user interface the way it is, my users will
> be ultra happy! That is the goal...
>
> In general, this is an inventory receiving piece of an overall larger
> web-based ERP system.
>
> What I have is a form in which I have a dynamic number of multline
> textareas for inputting (possibly barcode scanning in) many serial
> numbers per lineitem recieved.
>
> For example:
> lineitem01 = widget01; qtyReceived = 2;
> lineitem02 = widget02; qtyReceived = 3;
> lineitem03 = widget03; qtyReceived = 10;
>
> This would display a form that will generate 3 textarea elements (1
> per lineitem received). Inside each textarea element will be input the
> serial numbers for each of the widgets received per lineitem. i.e. 2
> serial numbers will be entered for widget01; 3 for widget02; and 10
> for widget03;
>
> So, what I am trying to do is pass this data over, possibly as a multi-
> dimensional array to another form ( or possibly
> $_SERVER['PHP_SELF'] ) to update a MySQL database to store the widget/
> serial numbers.
>
> Any ideas at all on how to approach this problem are welcomed.
>
> Thanks.

If you display the form like this:

<input type=hidden name=lineitems[] value="widget01">
<textarea name="widget01"></textarea>
<br><br>
<input type=hidden name=lineitems[] value="widget02">
<textarea name="widget02"></textarea>
<br><br>
<input type=hidden name=lineitems[] value="widget03">
<textarea name="widget03"></textarea>

Then when you post the data you can loop through the lineitems array
and get the entry for each textarea by using the value of the lineitem
like so:

foreach ($_POST['lineitems'] as $lineitem) {
$serial_text = $_POST[$lineitem];
$serials = explode("\n", $$serial_text);

// do whatever you need to do with each element serial for this
widget
// you also would want to trim() each item in the $serials array
before using it in case it has a left over \r in it
}

Hope this is answering the right question you had.

 

Navigation:

[Reply to this 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

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