I want to know how will I pass this table values using a form.
I have a list of products and each item belongs to a section and each section has different attributes. The attributes section are columns where the user can input a number of products he wants to buy that has the attribute.
Ex. I fetched this already in the database and have this output in a table.The forms looks like this.
Cellphones:
Item# Description Price Red Blue Total Unit Total
HOR-LPR Nokia N93 $500 1 3 4 $2000
Grand Total $2000
Game Consoles
Item# Description Price Red Black Pink Total Unit Total
OKL-JK Sony PSP $100 2 0 5 7 $700
YTL-OP Sony PS3 $200 1 0 0 1 $200
Grand Total: $900
Here's my code.
function displayOrderList() //function to display all product information in order form
{
global $database;
echo "<table class=sectionTable>";
$sections = $database->getSections();
foreach($sections as $section)
{
$section_id = $section['section_id'];
$section_name = $section['section_name'];
$section_description = $section['section_description'];
echo "
<tr>
<td id=section_name><h1 id='$section_name'>".$section_name."</h1></td>
</tr>
<tr>
<td>
<table border=1 class=itemTable cellspacing=0px cellpadding= 0px>
<tr>
<th>ITEM CODE</th>
<th>DESCRIPTION</th>
<th>UNIT PRICE</th>";
//display attributes columns for the section
$attributes = $database->getAttributes($section_id);
foreach ($attributes as $attribute)
{
$attribute_name=$attribute['attribute_name'];
echo "<th>".$attribute_name."</th>";
} //end of attribute headers
echo "
<th>TOTAL UNIT</th>
<th>TOTAL $</th>
</tr>";
$items = $database->getItems($section_id);
$row = 0;
foreach ($items as $item) //loop for product info
{
$item_id = $item['item_id'];
$item_number = $item['item_number'];
$item_description = $item['item_description'];
$item_price = $item['item_price'];
//set unique id for each input
$item_id = "item".$section_id."".$row;
$item_code = "item".$section_id;
$desc_id = "desc".$section_id."".$row;
$desc_name = "desc".$section_id;
$price_id = "price".$section_id."".$row;
$price_name = "price".$section_id;
$unit_id = "unit".$section_id."".$row;
$unit_name = "unit".$section_id;
$total_id = "total".$section_id."".$row;
$t_title = "total".$section_id;
$overall = "overall".$section_id;
$title;
echo "
<tr>
<td>".$item_number."</td>
<td id=description>".$item_description."</td>
<td>".$item_price."</td>";
$n = 0;
while ($n < sizeof($attributes)) //loop for attribute inputs
{
$attrib_id = "qty".$n."".$section_id."".$row;
$attrib_name = "qty".$n."".$section;
$title = "qty".$section_id."".$row;
echo "<td><input type=\"text\" size=4 name='$attrib_name'[] id='$attrib_id' title=\"".$title."\" value=\"0\" onkeyup=\"set_total(this.id,this.title,'$price_id','$unit_id','$total_id','$t_title','$overall')\"/></td>";
$n++;
} //end of attribute loop
echo "
<td>
<input type=\"text\" readonly class=\"product\" id=\"".$unit_id."\" name='$unit_name'[] value=\"0\" />
</td>
<td>
<input type=\"text\" readonly class=\"product\" title=\"".$t_title."\" id=\"".$total_id."\" name='$t_title'[] value=\"0\" />
</td>
</tr>
<input type=\"hidden\" name='$item_code'[] id=\"".$item_id."\" value=\"".$item_number."\" />
<input type=\"hidden\" name='$desc_name'[] id=\"".$desc_id."\" value=\"".$item_description."\" />
<input type=\"hidden\" name='$price_name'[] id=\"".$price_id."\" value=\"".$item_price."\" />";
$row++;
}//end of product loop
$colspan = 4 + sizeof($attributes);
echo "
<tr>
<td colspan=".$colspan." align=right>Grand Total:</td>
<td>
<input type=\"text\" readonly class=\"product\" name='overall[]' id='$overall' value=\"0\" />
</td>
</tr>
</table>
</td>
</tr>";
} //end of section loop
echo "</table>";
}
the code above is working I can display all the sections with its corresponding attributes and products... now I'm confused how can I pass all the values here to another page..(note: this is inside a form already) Can you give me some advice so I can pass all the values here?