Forum Moderators: coopster
<?php
$total = 0;
if (!empty($_POST['prices']))
{
foreach($_POST['prices'] as $cost)
{
$total = $total+$cost;
}
}
echo 'Final Total is: $'. $total;
?>
Something like that should be ok. Assuming you are using a multi select box?
dc
echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>Quantity</th>";
echo "<th>Price</th></tr>";
while ( $counter <= 100 ) {
echo "<tr><td>";
echo $counter;
echo "</td><td>";
echo $brush_price * $counter;
echo "</td></tr>";
$counter = $counter + 10;
}
echo "</table>";
HELLO dell.. say for example the above and you had multiple variables above instead of just 2; say you had 9 variables with = to a value sign.
and depending on which one was picked by the user - would output different prices
<?
// set the vars
$brush_price = 5;
$counter = 10;
echo "<form>";
echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>Quantity</th>";
echo "<th>Price</th>";
echo "<td> </td>";
echo "</tr>";
// do a for loop fot the array
for($count=0;$counter <= 100; $count+10)
{
echo "<tr><td>";
echo $counter;
echo "</td><td>";
$value = $brush_price * $counter;
echo $value;
// set the value for the checkbox to send the request
$val2 = $counter*$value;
echo "</td>";
// add checkbox
echo "<td><input type='checkbox' value='$val2' name='counter[]'></td>";
echo "</tr>";
$counter = $counter + 10;
}echo "<tr><td align=\"center\" colspan=\"3\">";
// submit button
echo "<input type='submit' name='subForm' value=\"calculate\">";
echo "</td></tr>";
echo "</table>";
echo "<form>";// show the outcome of all selected items?
if(!empty($_REQUEST['subForm']) &&!empty($_REQUEST['counter']))
{
echo 'Your total Cost is: £'.array_sum($_REQUEST['counter']);}
?>
Is this kind of what you are looking for?