├── Dockerfile ├── README.md ├── index.php └── simple_todo.sql /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.1-apache 2 | RUN apt-get update && docker-php-ext-install mysqli pdo && docker-php-ext-enable mysqli pdo 3 | COPY . /var/www/html/ 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 3tier_todo_app 2 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | alert('Todos Inserted');"; 11 | } 12 | }else{ 13 | echo ""; 14 | } 15 | 16 | 17 | } 18 | 19 | if (isset($_POST['todo']) && !empty($_POST['id']) ) { 20 | $id = $_POST['id']; 21 | $todo = $_POST['todo']; 22 | if(UpdateTodo($id,$todo,$connection)){ 23 | echo ""; 24 | } 25 | 26 | } 27 | 28 | if (isset($_GET['delete_id'])) { 29 | $id = $_GET['delete_id']; 30 | if (DeleteTodo($id,$connection) == true) { 31 | echo ""; 32 | } 33 | 34 | } 35 | if (isset($_GET['marking_id'])) { 36 | $id = $_GET['marking_id']; 37 | if (CompleteTodo($id,$connection)== true) { 38 | echo ""; 39 | } 40 | } 41 | 42 | function InsertTodo($todo,$connection) 43 | { 44 | 45 | $query = "INSERT INTO todos set todo = '$todo' "; 46 | $result = mysqli_query($connection,$query); 47 | if ($result == true) { 48 | return true; 49 | }else{ 50 | return false; 51 | } 52 | } 53 | 54 | function DeleteTodo($id,$connection) 55 | { 56 | $query = "Delete from todos where id = '$id' "; 57 | $result = mysqli_query($connection,$query); 58 | if ($result == true) { 59 | return true; 60 | }else{ 61 | return false; 62 | } 63 | } 64 | 65 | 66 | function CompleteTodo($id,$connection) 67 | { 68 | $query = "UPDATE todos set completed = 1 where id = '$id'"; 69 | $result = mysqli_query($connection,$query); 70 | if ($result == true) { 71 | return true; 72 | }else{ 73 | return false; 74 | } 75 | 76 | } 77 | if(isset($_POST['update'])){ 78 | $id = $_POST['update_id']; 79 | $data = GetTodo($id,$connection); 80 | } 81 | function GetTodo($id,$connection) 82 | { 83 | $query = "select * from todos where id = '$id' "; 84 | $result = mysqli_query($connection,$query); 85 | if ($result == true) { 86 | return mysqli_fetch_assoc($result); 87 | }else{ 88 | return false; 89 | } 90 | 91 | } 92 | function UpdateTodo($id,$todo,$connection) 93 | { 94 | $query = "Update todos set todo = '$todo' where id = '$id' "; 95 | $result = mysqli_query($connection,$query); 96 | if (mysqli_error($connection)) { 97 | die(mysqli_error($connection)); 98 | } 99 | } 100 | ?> 101 | 102 | 103 | 104 | 105 | 106 | A Basic Todo 107 | 142 | 143 | 144 |
145 |
146 |
147 |
148 | 149 | 150 | 151 |
152 |
153 |
154 |

155 | 156 | 161 |
162 | 163 | 164 |
165 | 166 | 167 |
168 | 171 | 172 | 173 |
174 |
175 | 176 |
177 | 178 | 179 | -------------------------------------------------------------------------------- /simple_todo.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.7.4 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: 127.0.0.1:3306 6 | -- Generation Time: Jul 02, 2018 at 11:36 AM 7 | -- Server version: 5.7.19 8 | -- PHP Version: 5.6.31 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET AUTOCOMMIT = 0; 12 | START TRANSACTION; 13 | SET time_zone = "+00:00"; 14 | 15 | 16 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 17 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 18 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 19 | /*!40101 SET NAMES utf8mb4 */; 20 | 21 | -- 22 | -- Database: `simple_todo` 23 | -- 24 | 25 | -- -------------------------------------------------------- 26 | 27 | -- 28 | -- Table structure for table `todos` 29 | -- 30 | 31 | DROP TABLE IF EXISTS `todos`; 32 | CREATE TABLE IF NOT EXISTS `todos` ( 33 | `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, 34 | `todo` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 35 | `completed` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0', 36 | `created_at` timestamp NULL DEFAULT NULL, 37 | `updated_at` timestamp NULL DEFAULT NULL, 38 | PRIMARY KEY (`id`) 39 | ) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 40 | 41 | -- 42 | -- Dumping data for table `todos` 43 | -- 44 | 45 | INSERT INTO `todos` (`id`, `todo`, `completed`, `created_at`, `updated_at`) VALUES 46 | (37, 'a simple todo list', '0', NULL, NULL), 47 | (38, 'I will go to peshawar', '0', NULL, NULL), 48 | (40, 'this is very bad', '0', NULL, NULL), 49 | (41, 'this is very bad', '0', NULL, NULL); 50 | COMMIT; 51 | 52 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 53 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 54 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 55 | --------------------------------------------------------------------------------