Forum Moderators: coopster
I've run into a problem - I would like to post an array that has association in it:
let me give you an example
<?php $names = array('coal', 'iron', 'brass');
echo '<form action="warehouse.php" name="warehouse" method="post">';
foreach($names as $name) {
echo '<input type="text" name="buy['.$name.']">';
echo '<input type="text" name="sell['.$name.']">';
}
echo '<input type="submit" name="action" value="Go">';
echo '</form>';
and what I would like to have is to receive two arrays:
$_POST['buy'] with "coal" => 2, "iron" => 4, "brass" => 0
and
$_POST['sell'] with "coal" => 0, "iron" => 0, "brass" => 8
However now on print_r($_POST) I get only Array ( [action] => Go )
Is that even possible?
I know that <input type="text" name="buy[]"> will work, but I loose then info about a material.
PS. inputs are db generated
Please provide any info.
Regards
Michal