Question

Platform: ssh server PHP and mySQL database Transaction Input: Transaction Name Transaction Type: Purchase, Income, Tax...

Platform:

  • ssh server
  • PHP and mySQL database

Transaction Input:

  • Transaction Name
  • Transaction Type: Purchase, Income, Tax Payment
  • Overall Amount
  • Number of unit and price for Purchase
  • Beneficiaries:(multiple choice of persons in the family)

Database record for each order:

  • All input information as above (multiple choices can be combined into one string and be stored in one field)
  • Transaction id

Basic functions on webpage

  1. Create a new transaction
  2. List all transactions
  3. Search Transaction by id

Bonus Functions

  1. Show the overall balance
  2. Search based on single beneficiary
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

For solving this question you need to create three php file
And One database table
Supposer I create three php file ie : Save.php, transaction.php, ShowTransaction.php

transaction .php

<?php

?>
<div>
<form action="Save.php" method="POST">
<table>
<tr>
<td>
<label>
Transaction Name
</label>

</td>
<td>
<input type="text" name="transaction_name"></input>
</td>
</tr>
<tr>
<td>
<label>
Transaction Type
</label>

</td>
<td>
<select name="transaction_type">
<option value="Purchase">Purchase</option>
<option value="Income">Income</option>
<option value="Tax">Tax</option>
</select>
</td>
</tr>
<tr>
<td>
<label>
Overall Amount
</label>

</td>
<td>
<input type="text" name="amount"></input>
</td>
</tr>
<tr>
<td>
<button type="submit"> Save Transaction</button>
</td>
<td>
<a href="ShowTransaction.php">View Previous Transaction</a>
</td>
</tr>
</table>
</form>

</div>

Save.php


<?php

$servername = "localhost";
$username = "root";/*database user name */
$password = "password";/*database user password */
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO test (transaction_name, transaction_type, amount)
VALUES ('".$_POST['transaction_name']."','".$_POST['transaction_type']."', '".$_POST['amount']."')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
<a href="transaction.php">Back To transaction</a>

ShowTransaction.php

<?php

$servername = "localhost";
$username = "root";/*database user name */
$password = "password";/*database user password */
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT transaction_name, transaction_type,amount FROM test";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row

$string = "<table style ='border: 1px solid black';
<tr style ='border: 1px solid black'><td style ='border: 1px solid black'>Transaction Name</td><td style ='border: 1px solid black'>Transaction Type</td><td style ='border: 1px solid black'>Amount</td></tr>";
while($row = $result->fetch_assoc()) {
$string .="<tr style ='border: 1px solid black'><td style ='border: 1px solid black'>" . $row["transaction_name"]. "</td><td style ='border: 1px solid black'>" . $row["transaction_type"]. "</td><td style ='border: 1px solid black'>" . $row["amount"]. "</td></tr>";
}
$string .= "</table>";
echo $string;
} else {
echo "0 results";
}
$conn->close();
?>
<a href="transaction.php">Back To transaction</a>


Table

Suppose my database name is Test and my table name is also Test you can change accordingly

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Platform: ssh server PHP and mySQL database Transaction Input: Transaction Name Transaction Type: Purchase, Income, Tax...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT