Hi, I'm trying to print a rental receipt. I enter a tenant name, amtpaid and amtdue into form and
expect to display the tenant name, amtpaid and balance due(if any). I'm also trying to update the
receiptno in the numberstbl and display the new one. I've tried echo, print and can't get the
values to display. please help.
the receipt code:
<?php
$server = "localhost";
$user = "root";
$password = "";
$dbname = "numbersdb";
// Create connection
$connection = mysqli_connect($server, $user, $password, $dbname);
// Check connection
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
SET receiptno = $receiptno + 1 where id=$id";
if (mysqli_query($connection, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($connection);
}
$tenant=$_POST['tenant'];
$amtpaid=$_POST['amtpaid'];
$amtdue=$_POST['amtdue'];
$id="id";
$receiptno='receiptno';
$baldue = $amtdue - $amtpaid;
echo "receiptno is $receiptno";echo "<br />";
?>
<!DOCTYPE html><html>
<head>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June","July",
"August","September","October","November","December" ];
var today = new Date();
var date = monthNames[today.getMonth()] + " - " + today.getDate() + " - " + today.getFullYear();
</script>
</head>
<body><center><b>
<font size="+1">Rent Receipt</font><br>
Date: <script type="text/javascript">document.write(date);</script><p>
<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br>
For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip"><br>
<b> tenant paying is: <?php echo $_POST["tenant"]; ?> -
Amount paid is: <?php echo $_POST["amtpaid"]; ?> -
echo "balance due is: $baldue";
</b><br>
<input type="text" size=85 name="sign" value="Management signature" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''">
<input type="text" size=15 name="thanks" readonly value="We Thank You:" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"><br>
</b></center></body></html>
the result:
"; ?>
Rent Receipt
Date: July - 26 - 2022
tenant paying is: - Amount paid is: - echo "balance due is: $baldue";
expect to display the tenant name, amtpaid and balance due(if any). I'm also trying to update the
receiptno in the numberstbl and display the new one. I've tried echo, print and can't get the
values to display. please help.
the receipt code:
<?php
$server = "localhost";
$user = "root";
$password = "";
$dbname = "numbersdb";
// Create connection
$connection = mysqli_connect($server, $user, $password, $dbname);
// Check connection
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
SET receiptno = $receiptno + 1 where id=$id";
if (mysqli_query($connection, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($connection);
}
$tenant=$_POST['tenant'];
$amtpaid=$_POST['amtpaid'];
$amtdue=$_POST['amtdue'];
$id="id";
$receiptno='receiptno';
$baldue = $amtdue - $amtpaid;
echo "receiptno is $receiptno";echo "<br />";
?>
<!DOCTYPE html><html>
<head>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June","July",
"August","September","October","November","December" ];
var today = new Date();
var date = monthNames[today.getMonth()] + " - " + today.getDate() + " - " + today.getFullYear();
</script>
</head>
<body><center><b>
<font size="+1">Rent Receipt</font><br>
Date: <script type="text/javascript">document.write(date);</script><p>
<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br>
For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip"><br>
<b> tenant paying is: <?php echo $_POST["tenant"]; ?> -
Amount paid is: <?php echo $_POST["amtpaid"]; ?> -
echo "balance due is: $baldue";
</b><br>
<input type="text" size=85 name="sign" value="Management signature" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''">
<input type="text" size=15 name="thanks" readonly value="We Thank You:" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"><br>
</b></center></body></html>
the result:
"; ?>
Rent Receipt
Date: July - 26 - 2022
tenant paying is: - Amount paid is: - echo "balance due is: $baldue";