├── img ├── 1.png ├── 2.png ├── 3.png └── screencapture-localhost-MySQL-table-main-index-php-2022-02-28-15_46_07.png ├── .gitattributes ├── src ├── navbar.php ├── incloudes.php ├── footer.php └── main │ ├── form.php │ └── tabel.php ├── README.md ├── index.php ├── process.php └── ahmed.sql /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mr-dev-dragon/MySQL-table/HEAD/img/1.png -------------------------------------------------------------------------------- /img/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mr-dev-dragon/MySQL-table/HEAD/img/2.png -------------------------------------------------------------------------------- /img/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mr-dev-dragon/MySQL-table/HEAD/img/3.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /img/screencapture-localhost-MySQL-table-main-index-php-2022-02-28-15_46_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mr-dev-dragon/MySQL-table/HEAD/img/screencapture-localhost-MySQL-table-main-index-php-2022-02-28-15_46_07.png -------------------------------------------------------------------------------- /src/navbar.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/incloudes.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mySQLL 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # If you r ready go [online](http://localhost/MySQL-table-main/index.php) 2 | 🚫you have to [download](https://github.com/Ahmed-Aoulad-Amar/MySQL-table/archive/refs/heads/main.zip) this project, put it inside the htdocs file in the php (MAMP)... server and 3 | come back [clike here](http://localhost/MySQL-table-main/index.php) and you r ready to go! 4 | 5 |                                                    ;      ❌ 6 |   if the page look like this that means that you have to  ❌ 7 |


8 | [![img](https://github.com/Ahmed-Aoulad-Amar/MySQL-table/blob/main/img/screencapture-localhost-MySQL-table-main-index-php-2022-02-28-15_46_07.png)](http://localhost/MySQL-table-main/index.php) 9 |
10 |
11 | # 1 12 | make sure that your php server or the databese doesn't have a password 13 | # 2 14 | creat a databese with name ahmed 15 | # 3 16 | copy that code from [ahmed.sql](https://github.com/Ahmed-Aoulad-Amar/MySQL-table/blob/main/ahmed.sql) and post it in the SQL Query saction in phpmyadmin 17 |
18 |
19 |
20 |
21 |
22 |
23 | # 24 | and there you go ✅ the page will look like this 25 | [![img](https://github.com/Ahmed-Aoulad-Amar/MySQL-table/blob/main/img/1.png)](http://localhost/MySQL-table-main/index.php) 26 | 27 | ✅ 28 | if you add a new row the form will pop-up 29 | [![img](https://github.com/Ahmed-Aoulad-Amar/MySQL-table/blob/main/img/2.png)](http://localhost/MySQL-table-main/index.php) 30 | ✅ 31 | if you try to delete a row a woring mesage will pop-up to make sur that you weant to delete it! 32 | [![img](https://github.com/Ahmed-Aoulad-Amar/MySQL-table/blob/main/img/3.png)](http://localhost/MySQL-table-main/index.php) 33 | -------------------------------------------------------------------------------- /src/footer.php: -------------------------------------------------------------------------------- 1 | 47 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 |
7 |
8 |
9 | 10 |
11 |
12 | 13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 | 21 | 22 |
23 |
24 | 27 | 28 | 29 | 62 |
63 | 66 | 67 | 70 | 73 |
74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /process.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | query("INSERT INTO `employees` ( `first_name`, `last_name`, `date_of_birth`, `department`, `salary`, `function`, `photo`) VALUES ('$first_name', '$last_name', '$date_of_birth', '$department', '$salary', '$f_unction', '$photo');") or die($mysqli->error()); 20 | $_SESSION['message'] = "Record has been saved!"; 21 | $_SESSION['msg_type'] = 'success'; 22 | $addbtn = true; 23 | header("location:index.php"); 24 | } 25 | else{ 26 | $addbtn = false; 27 | } 28 | 29 | 30 | 31 | 32 | 33 | 34 | if(isset($_GET['delete'])){ 35 | $id = $_GET['delete']; 36 | $mysqli->query("delete from employees where id = '$id'") or die($mysqli->error()); 37 | $_SESSION['message'] = "Record has been Delete!"; 38 | $_SESSION['msg_type'] = 'danger'; 39 | header("location:index.php"); 40 | } 41 | 42 | 43 | if (isset($_GET['edit'])){ 44 | $id = $_GET['edit']; 45 | $result = $mysqli->query("SELECT * FROM employees WHERE id=$id") or die($mysqli->error()); 46 | 47 | $row = $result->fetch_array(); 48 | $first_name = $row['first_name']; 49 | $last_name = $row['last_name']; 50 | $date_of_birth = $row['date_of_birth']; 51 | $department = $row['department']; 52 | $salary = $row['salary']; 53 | $f_unction = $row['function']; 54 | $photo = $row['photo']; 55 | $update = true; 56 | $addbtn = false; 57 | 58 | 59 | } 60 | else{ 61 | 62 | $first_name = ''; 63 | $last_name = ''; 64 | $date_of_birth = ''; 65 | $department =''; 66 | $salary = ''; 67 | $f_unction = ''; 68 | $photo = ''; 69 | $update = false; 70 | $addbtn = true; 71 | 72 | } 73 | 74 | if (isset($_POST['update'])){ 75 | $id = $_POST['id']; 76 | $first_name = $_POST['first-name']; 77 | $last_name = $_POST['last-name']; 78 | $date_of_birth = $_POST['date-of-birth']; 79 | $department = $_POST['department']; 80 | $salary = $_POST['salary']; 81 | $f_unction = $_POST['function']; 82 | $photo = $_POST['photo']; 83 | $mysqli->query("UPDATE employees SET first_name='$first_name', last_name='$last_name', date_of_birth='$date_of_birth', department='$department', salary='$salary', function='$f_unction' , photo='$photo' WHERE id='$id'")or die($mysqli->error()); 84 | $_SESSION['message'] = "the update was successful"; 85 | $_SESSION['msg_type'] = 'warning'; 86 | $addbtn = true ; 87 | 88 | header("Location:index.php"); 89 | 90 | } 91 | if (isset($_POST['addbtn'])){ 92 | 93 | $addbtn = false ; 94 | 95 | } 96 | 97 | 98 | 99 | 100 | ?> 101 | -------------------------------------------------------------------------------- /ahmed.sql: -------------------------------------------------------------------------------- 1 | 2 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 3 | START TRANSACTION; 4 | SET time_zone = "+00:00"; 5 | 6 | CREATE TABLE `employees` ( 7 | `id` int(11) NOT NULL, 8 | `first_name` varchar(30) NOT NULL, 9 | `last_name` varchar(30) NOT NULL, 10 | `date_of_birth` date NOT NULL, 11 | `department` varchar(50) NOT NULL, 12 | `salary` decimal(50,0) NOT NULL, 13 | `function` varchar(50) NOT NULL, 14 | `photo` varchar(500) NOT NULL 15 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 16 | 17 | INSERT INTO `employees` (`id`, `first_name`, `last_name`, `date_of_birth`, `department`, `salary`, `function`, `photo`) VALUES 18 | (87, 'ahmed ', 'AOULAD OUMAR', '1993-10-26', '#AIEN', '3000000', 'WEBDEVLOPER', 'https://raw.githubusercontent.com/code-brief/img/main/20200610_212959.jpg'), 19 | (88, 'trump', 'dounl', '2022-02-03', 'president ', '70000', 'president ', 'https://www.theglobeandmail.com/resizer/hNVMjr8hDGdPi6smvp-zWJbX4mI=/1200x0/filters:quality(80):format(webp)/arc-anglerfish-tgam-prod-tgam.s3.amazonaws.com/public/5HSZVXDII5BRRHH4S6KE4WZ7RE.jpg'), 20 | (93, 'Elon', 'mask', '2009-06-02', 'biasness', '10000000', 'conpany owner', 'https://cdn.vox-cdn.com/thumbor/RBwA33BWcDfnGZpubWFZLLb7hsA=/0x0:3926x3123/1220x813/filters:focal(1649x1248:2277x1876):format(webp)/cdn.vox-cdn.com/uploads/chorus_image/image/70305223/1234657391.0.jpg'), 21 | (94, 'aziz', 'akhanockh', '1999-02-02', 'prisdantdz', '1000', 'r', 'https://static.lematin.ma/files/lematin/images/articles/2021/10/15f905c648ac6c3fc451e5e4ede5d466.jpg'), 22 | (95, 'STIVE', 'jobe', '0034-03-05', 'pre', '5000000', 'sdfg', 'https://s.yimg.com/ny/api/res/1.2/AX5H0MqDU7xaHyAx2lSwRA--/YXBwaWQ9aGlnaGxhbmRlcjt3PTY0MDtoPTU4Mw--/https://s.yimg.com/uu/api/res/1.2/9j3ZjrbTmUxyQk.Ws.SYPw--~B/aD00NTA7dz00OTQ7YXBwaWQ9eXRhY2h5b24-/https://www.blogcdn.com/www.engadget.com/media/2011/10/steve-jobs.jpg'), 23 | (96, 'mohamed', 'salah', '1999-05-06', 'asdf', '10000', 'player', 'https://img.a.transfermarkt.technology/portrait/header/148455-1546611604.jpg'), 24 | (97, 'miss', 'lion', '1800-12-01', 'rdf', '300000', 'player', 'https://i.skyrock.net/3056/39483056/pics/1732872664.jpg'), 25 | (199, 'ahmed ', 'AOULAD OUMAR', '1993-10-26', '#AIEN', '3000000', 'WEBDEVLOPER', 'https://raw.githubusercontent.com/code-brief/img/main/20200610_212959.jpg'), 26 | (198, 'trump', 'dounl', '2022-02-03', 'president ', '70000', 'president ', 'https://www.theglobeandmail.com/resizer/hNVMjr8hDGdPi6smvp-zWJbX4mI=/1200x0/filters:quality(80):format(webp)/arc-anglerfish-tgam-prod-tgam.s3.amazonaws.com/public/5HSZVXDII5BRRHH4S6KE4WZ7RE.jpg'), 27 | (938, 'Elon', 'mask', '2009-06-02', 'biasness', '10000000', 'conpany owner', 'https://cdn.vox-cdn.com/thumbor/RBwA33BWcDfnGZpubWFZLLb7hsA=/0x0:3926x3123/1220x813/filters:focal(1649x1248:2277x1876):format(webp)/cdn.vox-cdn.com/uploads/chorus_image/image/70305223/1234657391.0.jpg'), 28 | (875, 'aziz', 'akhanockh', '1999-02-02', 'prisdantdz', '1000', 'r', 'https://static.lematin.ma/files/lematin/images/articles/2021/10/15f905c648ac6c3fc451e5e4ede5d466.jpg'), 29 | (7989, 'STIVE', 'jobe', '0034-03-05', 'pre', '5000000', 'sdfg', 'https://s.yimg.com/ny/api/res/1.2/AX5H0MqDU7xaHyAx2lSwRA--/YXBwaWQ9aGlnaGxhbmRlcjt3PTY0MDtoPTU4Mw--/https://s.yimg.com/uu/api/res/1.2/9j3ZjrbTmUxyQk.Ws.SYPw--~B/aD00NTA7dz00OTQ7YXBwaWQ9eXRhY2h5b24-/https://www.blogcdn.com/www.engadget.com/media/2011/10/steve-jobs.jpg'), 30 | (778, 'mohamed', 'salah', '1999-05-06', 'asdf', '10000', 'player', 'https://img.a.transfermarkt.technology/portrait/header/148455-1546611604.jpg'), 31 | (975, 'miss', 'lion', '1800-12-01', 'rdf', '300000', 'player', 'https://i.skyrock.net/3056/39483056/pics/1732872664.jpg'); 32 | 33 | 34 | ALTER TABLE `employees` 35 | ADD PRIMARY KEY (`id`); 36 | 37 | ALTER TABLE `employees` 38 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=98; 39 | COMMIT; 40 | -------------------------------------------------------------------------------- /src/main/form.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 |
6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 |
31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 44 | 45 | 46 | 48 | 49 | 50 | 51 |
52 | 53 | 54 |
55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 |
64 | 65 | 66 |
67 | 68 | 69 | 70 | 72 | 73 | 74 | 75 |
76 | 77 | 78 |
79 | 80 | 81 | 82 | 84 | 85 | 86 | 87 |
88 |
89 | 90 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 |
125 | 126 |
127 | 128 | -------------------------------------------------------------------------------- /src/main/tabel.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 |
6 | 10 |
11 | 12 | query(" SELECT * FROM `employees` ") ; 15 | 16 | ?> 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | fetch_assoc()): ?> 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 93 | 94 | 95 | 96 |
#first namelast namedate of birthdepartmentsalaryfunctionphotoaction
$ 43 | this is a employees photo 45 | Edit 47 | 90 | Delte 92 |
97 | 98 | 99 | 100 | 101 | --------------------------------------------------------------------------------