Hi, I am pretty new on php, and have been trying to solve a problem I
am having for the past 2 days.
I have a HTML page which is going to have a form and some of the
fields in the form will work like a table to allow the user to enter
up to 15 lines on information on 4 columns, this application is to
allow someone to enter a recipe into a database, so we will have 15
lines to allow people to enter: Quantity, Mesasure, Ingredient, and a
flag to indicate if is optional or not.
So I tought that would be better to create a bi-dimensional array and
pass it to the php code that is called when submit is hit. So here is
what I have done:
IN THE HTML FILE:
....
<form action="insert_recipe.php" method="POST">
<?php
$ingr_array = array(array());
?>
....
some code...
....
<tr>
<td align="center" class="cellbg"><input type="text" name="<?php
$ingr_array[0][0] ?>" ID="quantity0" size="5"
class="defaultfont"></td>
<td align="center" class="cellbg"><input type="text" name="<?php
$ingr_array[0][1] ?>" ID="measure0" size="20"
class="defaultfont"></td>
<td align="center" class="cellbg"><input type="text" name="<?php
$ingr_array[0][2] ?>" ID="ingredient0" class="defaultfont"
size="27"></td>
<td align="center" class="cellbg"><input type="checkbox" name="<?php
$ingr_array[0][3] ?>" ID="optional0" class="defaultfont"></td>
</tr>
// 14 more of this...
and then on my insert_recipe.php I am trying to check If I got
something using these debug messages:
echo "Size of array is ".sizeof($ingr_array)."<BR>";
echo "Quantity is ".$ingr_array[0][0]."<BR>";
echo "Measure is ".$ingr_array[0][2]."<BR>";
echo "Ingredient is ".$ingr_array[0][2]."<BR>";
So when I type any data in the form and hit the submit button, I got
the following displayed:
Size of array is 0
Quantity is
Measure is
Ingredient is
Any idea on what I can be doing wrong here ?
Thanks in advance for any help on this.
M.D.