Jump to content

starkytwo

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by starkytwo

  1. Thanks thats got rid of the intial error I had. However I do not understadn what to put inbetween the '' in the code you just suggested? if(!isset($plusvat)){ $plusvat = ''); }
  2. Thanks for the reply, I see what you mean about the if statement not being run, however I dont understand where you suggest I place the "else" statement? - sorry but I'm a bit of a novice! Could you show me more specifically where the "else" should go?
  3. Hi there Im trying to sort out some code for a simple ordering process. I have a php form that lists the items from a .txt file with checkboxes where the user can then select items. However on the next form I cant get the form to display the itesm selected and their prices to calculate VAT and total cost etc. Im getting the following error when I try to process this second form: Notice: Undefined variable: plusvat in /nas/........ Heres the form I'm trying to pull the data from: <form action="purchases2.php" method="post"> <table border="2" cellpadding="5" cellspacing="5" width="50%"> <tr> <th> Image </th> <th> Description </th> <th> Sport </th> <th> Price </th> <th> Please Select </th> </tr> <?php if(!($lines = file('itemlist.txt'))) {echo 'ERROR: Unable to open file! </body></html>'; exit;} foreach($lines as $theline) { list($itemid, $sport, $description, $price, $image) = split('\|',$theline); echo " <tr> <td><img src='$image' width='45' height='45'></td> <td> $description </td> <td> $sport </td> <td> $price </td> <td> <input type='checkbox' name='$theline' </td> </tr> "; } ?> and here is the php code i currently have that I want to retrieve the items price and description from a .txt file and manipulate the data to get VAT prices etc. <form action="ordersummary2.php" method="post"> <?php $total="0"; foreach ($_POST as $varname => $varvalue) { if(!($lines = file('itemlist.txt'))) {echo 'ERROR: Unable to open file! </body></html>'; exit;} foreach($lines as $theline) { list($itemid, $sport, $description, $price, $image) = split('\|',$theline); if ($varname==$varvalue) { echo " <br/><br/> <tr> <input type='hidden' name='itemcode' value=$itemid> <td><align='center'> Item Number: $itemid </td> <input type='hidden' name='description' value=$description> <td><align='center'> Item Chosen: $desciption </td> <input type='hidden' name='price' value=$price> <td><align='center'> Price: $price </td> <td><align='center'><img src='$image' width='70' height='70'></td> </tr>"; $total=$total+$price; $plusvat=number_format($total*1.175,2); }}} echo " <br> <tr> <td aliign='left'> Total Excluding VAT: </td> <td> $total </td> </tr> <br> <tr> <td align='left'> Total Including VAT: </td> <td> $plusvat </td> </tr>"; ?> Can anyone spot any obvious mistakes I have made Thanks in advnace and sorry if i have included irrelevant code!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.