Mailinglisten-Archive |
Michael Borchers wrote:
> das skript soll zu jedem input feld eine stückzahl liefern
> und das ergebnis in einen string übergeben.
>
> da gibt es doch sicherlich eine einfachere schriftweise, oder?!
lässt sich schelcht sagen, weiß ja keiner wofür es ist, also wie es
verwendet werden soll ...
>
> <?php
> $typ = $_POST['typ'];
> $stck = $_POST['stck'];
>
> for ($t=0;$t<count($typ);$t++)
> {
> if ($stck[$t] != "0")
> {
> $typ_array[] = $stck[$t] . "x " . $typ[$t];
> }
> }
>
> $typ_array_count = count($typ_array);
>
> for($akf=0;$akf<$typ_array_count;$akf++)
> {
> $text = $text . $typ_array[$akf] . "<br>\n";
> }
>
> echo "Text: $text";
> ?>
>
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
> typ 1:<input type="text" name="typ[]" value="1"> stck 1:<input type="text" name="stck[]" value="4"><br>
> typ 2:<input type="text" name="typ[]" value="2"> stck 2:<input type="text" name="stck[]" value="0"><br>
> typ 3:<input type="text" name="typ[]" value="3"> stck 3:<input type="text" name="stck[]" value="5"><br>
> <input type="submit" name="ok">
> </form>
// typ => stück
$items = array(
1 => 4,
2 => 0,
3 => 5,
)
foreach ( $items as $typ => $stck )
{
echo 'typ ' . $typ . ':' .
'<input type="text" name="items[' . $typ . '][typ]"
value="' . $typ . '" />' .
'stck ' . $typ . ':' .
'<input type="text" name="items[' . $typ . '][stck]"
value="' . $stck . '" />' .
'<br />';
}
------
$items = array;
foreach ( $_REQUEST['items'] as $item )
{
$items[$items[typ]] = $item[stck]
}
--
Sebastian Mendel
www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet
php::bar PHP Wiki - Listenarchive