Jump to content

form fields


webchambers1

Recommended Posts

Hi Guys i need help on a small matter.

if you go to https://www.mywebchambers.co.uk/invoiceman/form.php

when submitted all works ok.

However if you delete rows 3, 4 and 5 and submit the page shows a value of 0.00 in the total column on rows 3, 4 and 5.

How do i get this value removed so it is blank same as the rest ?

 

My form action is toolstation3.php code below

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Toolstation</title>
<meta name="generator" content="WYSIWYG Web Builder 14 - http://www.wysiwygwebbuilder.com">
<link href="toolstation.css" rel="stylesheet">
<link href="toolstation.css" rel="stylesheet">
</head>
<body>

<?php

{$orderno =($_POST["orderno"]);}
{$date =($_POST["date"]);}
{$totalvalue =($_POST["totalvalue"]);}
{$code1 =($_POST["code1"]);}
{$name1 =($_POST["name1"]);}
{$price1 =($_POST["price1"]);}
{$amount =($_POST["amount"]);}
{$quantity1 =($_POST["quantity1"]);}
{$total =($_POST["total"]);}
{$contact1 =($_POST["contact1"]);}
{$contact2 =($_POST["contact2"]);}
{$contact3 =($_POST["contact3"]);}
{$contact4 =($_POST["contact4"]);}
{$contact5 =($_POST["contact5"]);}
{$depot =($_POST["depot"]);}
{$company =($_POST["company"]);}
{$title =($_POST["title"]);}
{$firstname =($_POST["firstname"]);}
{$lastname =($_POST["lastname"]);}
{$mobile =($_POST["mobile"]);}
{$email =($_POST["email"]);}
{$vatband1 =($_POST["vatband1"]);}


{$code2 =($_POST["code2"]);}
{$name2 =($_POST["name2"]);}
{$price2 =($_POST["price2"]);}
{$quantity2 =($_POST["quantity2"]);}
{$vatband2 =($_POST["vatband2"]);}

{$code3 =($_POST["code3"]);}
{$name3 =($_POST["name3"]);}
{$price3 =($_POST["price3"]);}
{$quantity3 =($_POST["quantity3"]);}
{$vatband3 =($_POST["vatband3"]);}

{$code4 =($_POST["code4"]);}
{$name4 =($_POST["name4"]);}
{$price4 =($_POST["price4"]);}
{$quantity4 =($_POST["quantity4"]);}
{$vatband4 =($_POST["vatband4"]);}

{$code5 =($_POST["code5"]);}
{$name5 =($_POST["name5"]);}
{$price5 =($_POST["price5"]);}
{$quantity5 =($_POST["quantity5"]);}
{$vatband5 =($_POST["vatband5"]);}

{$sum1 =($_POST["sum1"]);}
{$sum2 =($_POST["sum2"]);}
{$sum3 =($_POST["sum3"]);}
{$sum4 =($_POST["sum4"]);}
{$sum5 =($_POST["sum5"]);}

{$nil =($_POST["nil"]);}


{$net =($_POST["net"]);}
{$vat =($_POST["vat"]);}
{$percentage =($_POST["percentage"]);}


$sum1=$quantity1*$price1;
$sum2=$quantity2*$price2;
$sum3=$quantity3*$price3;
$sum4=$quantity4*$price4;
$sum5=$quantity5*$price5;

$net=$sum1+$sum2+$sum3+$sum4+$sum5;

$total=$net+$vat;
$vatrate=20;
$vat=$net/100*20;
$total=$net+$vat;

$sum1 = number_format($sum1, 2, '.', '');
$sum2 = number_format($sum2, 2, '.', '');
$sum3 = number_format($sum3, 2, '.', '');
$sum4 = number_format($sum4, 2, '.', '');
$sum5 = number_format($sum5, 2, '.', '');


$net = number_format($net, 2, '.', '');
$vat = number_format($vat, 2, '.', '');
$total = number_format($total, 2, '.', '');

if(empty($_POST['quantity3']) && empty($_POST['price3'])) {echo " $nil";}
$nil='';


echo "<H3> &nbsp&nbsp Toolstation Invoice";

echo "<br>&nbsp&nbsp&nbsp____________________________________________________________________________________________________<br><br>";

echo "<H3> &nbsp&nbsp Address &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Details  ";

echo "<br>&nbsp&nbsp&nbsp___________________________________________________________ &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp____________________________________<br><br>";


echo "<table cellpadding=3 border=0 style='float:left'>";

echo "<tr>
<td>Contact<br><br>$contact1<br>$contact2<br>$contact3<br>$contact4<br>$contact5</td>
</td>";
echo "</table>";


echo "<table cellpadding=3 border=0 style='float:left'>";

echo "<tr>
<td>Delivery<br><br>$contact1<br>$contact2<br>$contact3<br>$contact4<br>$contact5</td>
</td>";
echo "</table>";

echo "<table cellpadding=3 border=0 style='float:left'>";

echo "<tr>
<td>Payment &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<br><br>$contact1<br>$contact2<br>$contact3<br>$contact4<br>$contact5</td>
</td>";
echo "</table>";

echo "<table cellpadding=3 border=0 style='float:left'>";

echo "<tr> 
<td>Order No<br>Placed On<br>Completed On<br>Total Value<br>Currency<br>Depot<br>Payment<br>UID<br>Company<br>Title<br>First Name<br>Last Name<br>Mobile<br>E Mail</td>
</td>";
echo "</table>";

echo "<table cellpadding=3 border=0>";

echo "<tr>
<td>QR4298562763000001<br>$date<br>$date<br>$total<br>GBP<br>Rotherham (R4)<br>Cash<br>CWW01074397<br>$company<br>$title<br>$firstname<br>$lastname<br>$mobile<br>$email</td>
</td>";
echo "</table>";

echo "<H3> &nbsp&nbsp Items";

echo "<br>&nbsp&nbsp&nbsp__________________________________________<br><br>";


echo "<table cellpadding=3 border=1>";

echo "<tr><th>Code</th><th>Name</th><th>Quantity</th><th>Price</th><th>Total</th><th>Vat Band</th></tr>";

echo "<tr><td>$code1</td><td>$name1</td><td>$quantity1</td><td>$price1</td><td>$sum1</td><td>$vatband1</td> ";

echo "<tr><td>$code2</td><td>$name2</td><td>$quantity2</td><td>$price2</td><td>$sum2</td><td>$vatband2</td> ";

echo "<tr><td>$code3</td><td>$name3</td><td>$quantity3</td><td>$price3</td><td>$sum3</td><td>$vatband3</td> ";

echo "<tr><td>$code4</td><td>$name4</td><td>$quantity4</td><td>$price4</td><td>$sum4</td><td>$vatband4</td> ";

echo "<tr><td>$code5</td><td>$name5</td><td>$quantity5</td><td>$price5</td><td>$sum5</td><td>$vatband5</td> ";


echo "</table>";

echo "<br>";

echo "<H3> &nbsp&nbsp VAT Analysis";

echo "<br>&nbsp&nbsp&nbsp__________________________________________<br><br>";

echo "<table cellpadding=5 border=1>";

echo "<tr><th>Band</th><th>Rate</th><th>Net</th><th>VAT</th><th>Total</th></tr>";

echo "<tr><td>5</td><td>20%</td><td>$net</td><td>$vat</td><td>$total</td> ";


echo "</table>";


?>

<div id="container">
</div>
</body>
</html>

 

Link to comment
Share on other sites

PHP keeps the original data type unless you specifically change it. Thus it will always be data type float and will output 0.0. If you want it to be blank then add a check to see if it is 0, if it is then do not output the variable. Because you didn't use the proper code icon (<>) I am not going to wade through that difficult to read code but wherever you are outputting that variable, add the 'if' block.

Edited by gw1500se
Link to comment
Share on other sites

2 hours ago, webchambers1 said:

&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp

Really!?

Hard to believe that, with your markup, you are actually using css files.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.