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
  • 1. Write the php statements to connect to MySQL server and select the database named personnel....

    1. Write the php statements to connect to MySQL server and select the database named personnel. The database personnel is located at localhost server. The user id and password to log on to the server are finalexam and thePassword respectively. 2. Using the above connection, write the php statements to retrieve the name and the email fields from all records of the users table ( 'SELECT name, email FROM users') and display them one record per line.

  • This is a website picture The html and css code is as follow And my problem is as follow use the php and mysql Northwind Customer Database Search List Records All Records CustomerName v CustomerName...

    This is a website picture The html and css code is as follow And my problem is as follow use the php and mysql Northwind Customer Database Search List Records All Records CustomerName v CustomerName ContactName Address City PostalCode Search O ASC DESC List All Records Insert Record Country List City CustomerName ContactName Address City PostalCode Country List City Find by IID Find Insert 1 <! DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http:L 3-<head> 4 Kmeta http-equiv-"Content-Type" content-"text/html; charset-utf-8" />...

  • A test specification provides designers with what needs to be known in order to perform a...

    A test specification provides designers with what needs to be known in order to perform a specific test, and to validate and verify the requirement to be tested. The test script is divided into the test script, which is the generic condition to be tested, and one or more test cases within the test script. Provide a test script and test case for at least 3 of your requirements identified in your requirements specification. Provide the following format for an...

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