Hello all,
long time no post! I have missed php!!
Thanks in advance for any advice!!
I am trying to add an updating price variable to 0 to give a total price, eg someone selects how many items they want, these are listed and the total price is added, however it seems to keep giving me the final price of the last item in my flat file database - whether or not it is selected as an item....
here is my code!
<?php
$var=0;
foreach ($_POST as $ID2 => $price) {
if(!($lines = file('php_ffdb.txt')))
{echo 'ERROR: Unable to open file! </body></html>'; exit;}
foreach($lines as $theline) {
list($ID, $title, $author, $description, $price, $image) = split('\|',$theline);
if($ID==$ID2)
{
echo " <table>
<tr>
<td>
$price</td>
<td>$ID</TD>
</TABLE>
";
}
}
$sum=$var + $price;
echo("$sum");
}
?>
Any advice would be great!!
Thanks!!!
Will