Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $pageTitle = "Expenses";
- include 'E:/xampp/htdocs/HomeworkNo1/includes/header.php';
- require 'E:/xampp/htdocs/HomeworkNo1/includes/constants.php';
- ?>
- <h3><a href="http://localhost/HomeworkNo1/Addnewexpense.php">Add new expense</a></h3>
- <?php $category = (int) $_GET['sortid'] ?>
- <form method="GET" action="index.php">
- Type: <select name="sortid">
- <?php
- foreach ($type as $key => $value) {
- echo '<option value="' . $key . '">' . $value . '</option></li>';
- }
- ?>
- </select>
- <input type="submit" value="Filter"/>
- </form>
- <table border="1">
- <tr>
- <td>Name</td>
- <td>Type</td>
- <td>Date</td>
- <td>Cost</td>
- </tr>
- <?php
- if (file_exists('data.txt')) {
- $result = file('data.txt');
- $sum = 0;
- foreach ($result as $value) {
- $columns = explode('@', $value);
- if ($category == $columns[1]) {
- echo '<tr><td>' . $columns[0] . '</td><td>' . $type[trim($columns[1])] .
- '</td><td>' . $columns[2] . '</td><td>' . $columns[3] . '</td></tr>';
- $sum += $columns[3];
- }
- }
- }
- if ($sum == 0) {
- echo '<tr><td colspan="4">Няма резултати.</td></tr>';
- }
- ?>
- </table>
- <?php
- include 'E:/xampp/htdocs/HomeworkNo1/includes/footer.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment