This is an Expense Tracker Web App that tracks the way you spend your income. It's simple and easy to use. The application contains the CRUD Operations or (Create, Read, Update, and Delete). The system stores the categories of expenses along with the amount to spend. Every time you create or add a new expense record, the balance will automatically calculate to show you your balance for each category. All expense records added will be listed and can be deleted on the expense report page.
Script of saving the Expense Category in the database.
<?php require_once('db_config.php'); // echo print_r($_POST); $sql = "SELECT expense_category_name FROM expense_category_tbl WHERE expense_category_name = '$expense_category_name' "; echo ' <script type="text/javascript"> </script>'; } $data = mysqli_query($con, "INSERT INTO expense_category_tbl(expense_category_name, created_at, amount) VALUES('".$expense_category_name."', '".$created_at."','".$amount."')"); } //if data inserted successfully if(@$data === TRUE) { echo ' <script type="text/javascript"> alert("Success!"); </script>'; } else{ $message = "All fields are required"; } ?>
Updating the Expense Category Details
<?php require_once('db_config.php'); $update = mysqli_query($con, "UPDATE expense_category_tbl SET amount = '".$amount."', expense_category_name= '".$expense_name."' WHERE expense_category_id = '".$expense_category_id."' "); if($update === TRUE) { echo ' <script type="text/javascript"> alert("Success!"); window.location.replace("expense_category.php"); </script>'; } else{ echo ' <script type="text/javascript"> alert("Error!"); window.location.replace("update.php "); </script>'; } } ?>
Add New Expense
<?php require_once('db_config.php'); //A function to get difference between to numbers function diff($a=0, $b=0){ $c = ($a - $b); return $c; } $zero ='0'; //get a particular row amount and expense_name $getAll = mysqli_query($con, "SELECT expense_category_name, amount FROM expense_category_tbl WHERE expense_category_id ='".$expense_category_id." ' "); { $_amount = $row['amount']; //SET AMOUNT $_expense_category_name = $row['expense_category_name']; } $getBal = mysqli_query($con, "SELECT expense_category_id, SUM(amount_spent) AS amount_spent FROM expense_tbl WHERE expense_category_id ='".$expense_category_id." ' GROUP BY expense_category_id "); $sum=0; $_amount_spent = $row['amount_spent']; $sum += $_amount_spent; } $sum; $balance = $_amount - $sum; if($balance < 0) { echo ' <script type="text/javascript"> </script>'; } $data = mysqli_query($con, "INSERT INTO expense_tbl(expense_category_id,expense_description,expense_date,created_at,deleted,amount_spent) VALUES('".$expense_category_id."','".$expense_description."','".$expense_date."','".$created_at."','".$zero."','".$amount_spent."')"); } //if data inserted successfully if(@$data === TRUE) { echo ' <script type="text/javascript"> alert("Success!"); </script>'; } else{ $message = "All fields are required"; } ?>
The Source Code is free to download. Feel Free to download and modify the source code the way you wanted. This may help other programmers specially for those who are new in PHP Language.
Apache
and MySQL
.PHPMyAdmin
in a browser. i.e. http://localhost/phpmyadmin
expense_tracker
.SQL
file. The file is known as expense_tracker.sql
located inside the db_script folder.http://localhost/expense_tracker
.I hope this will help you with what you looking for and you'll find something useful for your future projects. For any queries you can contact me @ [email protected].
Enjoy :)Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.