I parse the database using each array item as a unique ID and retrieve the product info taken from each ID in the array.
When the product info is displayed, it is done so inside a form. The price for each product is displayed in a Text Field box, so if a customer gets a discount, the price may be edited. There could be man Text Field boxes, depending on how many products have been chosen.
I want to then be able to take the product_id and new adjusted prices from each product (if any were adjusted) and use them later for totals, stock control etc, but the problem I'm facing is, the Text Fields are drawn in a loop, and I am unsure of how to retrieve the data. See this code for the problem:
Code: Select all
foreach($services as $val)
{
$sql = "SELECT * FROM services WHERE id = $val";
$content = mysql_query($sql);
$Xcontent = mysql_fetch_array($content);
$service_id = $Xcontent["id"];
$service_name = $Xcontent["name"];
$service_description = $Xcontent["description"];
$service_price = $Xcontent["price"];
if ($val == $service_id)
{
echo "
<tr>
<td class=\"clientview\"><div align=\"center\">$service_name</div></td>
<td class=\"clientview\"><div align=\"center\">$$service_price</div></td>
<td class=\"clientview\"><div align=\"center\"><input name=\"adjusted_service_price\" type=\"text\" value=\"$service_price\" size=\"3\" maxlength=\"4\"></div></td>
";
}
}This could be overcome by supplying each Text Edit box with a unique name, ie, make the name value adjusted_service_price
I really hope that makes sense and I really hope someone has some ideas. It's been working this brain of mine over for two days now whilst I work on other things to keep moving but the time has come, it has to be sorted. Any help would be GREATLY appreciated.