Change the textfields name into these: Pepsi_Cola , Coca_Cola , Beer
and use like this
<?
if(isset($_POST))
{
$items="Pepi_Cola#Coca_Cola#Beer"; //you could store the items in an array
$prices["Pepi_Cola"]="1";
$prices["Coca_Cola"]="1";
$prices["Beer"]="1";
$it=explode("#",$items);
foreach($it AS $item)
{
$it_name=str_replace("_"," ",$item);
if(gettype($_POST[$item])=="integer") //if the user wrote a number, check woth gettype
{
$sub_total=($_POST[$item] * $prices[$item]); //count the subtotal with a *
print $it_name . " " . $_POST[$item]. " =" . $sub_total ."\$ <br>"; //print the subtotals with the selected amounts too.
$total+=$sub_total; //inrcease the $total's value with the subtotal.
}
else //if its not a number
{
print "$it_name 0 - 0 \$"; //just print the 0 values to the visitor.
}
}
if($total>0)
print "Total:".$total."\$"; //and the total of a bill ...
else
print "Total: 0\$";
}
if (isset($_POST["txtmanual"]))
print "<hr>".$_POST["txtmanual"];
?>
And here is the form
<form name="myform" method="post" action="customize_service.php">
<table width="888" border="0">
<tr class="rowstyle">
<td colspan="3">pepsi
</td>
<td width="468"><input type="text" name="Pepsi_Cola"></td>
</tr>
<tr>
<td colspan="3">Coca cola</td>
<td><input type="text" name="Coca_Cola"></td>
</tr>
<tr>
<td colspan="3">beer</td>
<td><input type="text" name="Beer"></td>
</tr>
<tr>
<td colspan="3">Manual submission to major search engines and directories</td>
<td><input type="text" name="txtmanual"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
?>[QUOTE=homez_jenny;10891595]I have a following form---
<form name="myform" method="post" action="customize_service.php">
<table width="888" border="0">
<tr class="rowstyle">
<td colspan="3">pepsi
</td>
<td width="468"><input type="text" name="txtlink"></td>
</tr>
<tr>
<td colspan="3">Coca cola</td>
<td><input type="text" name="txtarticle"></td>
</tr>
<tr>
<td colspan="3">beer</td>
<td><input type="text" name="txtblog"></td>
</tr>
<tr>
<td colspan="3">Manual submission to major search engines and directories</td>
<td><input type="text" name="txtmanual"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
In the above form, there are some price associated with each item. For eg: 1 Pepsi costs $2, Coca cola costs $1 and 1Beer cost $5.
Now when someone enters 3 in the first text box, it should get a result-> $2 * 3(no. of Pepsi) = $6 and hence forth.
And at the end I should get a total bill mentioning
please help..😕
Thank you so much.[/QUOTE]