You are on page 1of 9

MAURICE MUTETI

Everything Goes Here

HOME SAMPLE PAGE

How To Insert, Delete, Edit, Search … 

Update And Select Data From Recent Posts


Mysql Database Using Php, Sql,
How To Insert, Delete, Edit,
Html And Css Tutorial Update And Select Data From
Mysql Database Using Php,
 by admin  June 4, 2019
Sql, Html And Css Tutorial

How To Populate Html Table


With Data From Mysql
How To Insert, Delete, Edit, Update And Select Data From Mysql
Database Using Php,Sql And
Database Using Php, Sql, Html And Css Tutorial – Source Code
Html Tutorial

How To Upload,Insert Image


INSERT DELETE EDIT UPDATE SELECT DA… As A Blob In Mysql Database
Watch later Share
And Display It Using Php

How To Upload Image In


Mysql Database And Display
It On A Webpage Using Php
Html

UPLOAD AND INSERT IMAGE


INTO MYSQL DATABASE
USING HTML SQL PHP

Recent Comments

PDFmyURL easily turns web pages and even entire websites into PDF!
You can update, delete, select and insert data into mysql database
using php, html, sql easily using the code below. To delete, select and
Archives
update data, you must first insert it in the database. After you click
insert button the data is inserted in mysql database. And also June 2019
displayed on html table. To delete the data, click delete button next to
the row with the data you want to delete. Editing the data in a no- Categories
brainer, just click edit button or link next to the data you want to edit,
Uncategorized
the data will be displayed on the input boxes, just edit it and enter the
required data and finally click save.
Meta
1 insertdeleteedit.php
2 <?php Log in
3
4 include("db.php"); Entries RSS
5 if(isset($_POST&#91;'submitinserdetails'&#93;
6 $firstname = $_POST&#91;'firstname'&#93;; Comments RSS
7 $lastname = $_POST&#91;'lastname'&#93;;
8 $email = $_POST&#91;'email'&#93;;
9 if(!empty($firstname) && !empty($lastname) && WordPress.org
10 $sql = "INSERT INTO `insertdeleteedittable`
11 VALUES
12 $qry = mysqli_query($connect, $sql);
13 if($qry) {
14 echo "inserted successfully";
15 }
16 } else {
17 echo "all fields must be filled";
18 }
19 }
20
21 ?>
22
23
24
25 <!DOCTYPE html>
26 <html>
27 <head>
28 <title></title>
29 </head>
30 <body>
31 <form action="" method="POST">
32 <input type="text" name="firstname"><br ><br
33 <input type="text" name="lastname"><br ><br >
34 <input type="text" name="email"><br ><br >
35 <input type="submit" name="submitinserdetails
36
PDFmyURL easily turns web pages and even entire websites into PDF!
37 </form>
38 </body>
39 </html>
40
41
42
43 db.php
44
45
46
47 <?php
48 $connect = mysqli_connect("localhost", "root"
49 if ($connect) {
50 echo "<br/> Connected to server";
51 }else{
52 die("<br />Connection error ". mysqli_connect
53 }
54 $selectdb = mysqli_select_db($connect, "inser
55 if ($selectdb) {
56 echo "<br />Existing Database Selected";
57 } else {
58 $sqlcreatedb = "CREATE DATABASE IF NOT EXISTS
59 if (mysqli_query($connect, $sqlcreatedb)) {
60 echo "<br />New database created";
61 $selectdb2 = mysqli_select_db($connect, "inse
62 if ($selectdb2) {
63 echo "<br />Created database selected";
64 $sqlcreatetable = "
65 CREATE TABLE IF NOT EXISTS `insertdeleteeditt
66 `id` int(11) NOT NULL AUTO_INCREMENT,
67 `firstname` varchar(100) NOT NULL,
68 `lastname` varchar(100) NOT NULL,
69 `email` varchar(100) NOT NULL,
70 PRIMARY KEY (`id`)
71 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
72 ";
73 if (mysqli_query($connect,$sqlcreatetable)) {
74 echo "<br />New table created";
75
} else {
76 echo "<br />No table created";
77 }
78 }
79
} else {
80
echo "<br />No database created";
81
82 }
83 }
84 ?>
85
86
87
display.php
88
89
PDFmyURL easily turns web pages and even entire websites into PDF!
90
91
92 <?php
93 include("db.php");
94 ?>
95 <!DOCTYPE html>
96 <html>
97 <head>
98 <title></title>
99 <style type="text/css">
100 table {
101 border:1px solid black;
102 border-collapse: collapse;
103 }
104 td{
105 border:1px solid black;
106 padding: 10px;
107 }
108
109 </style>
110
111 </head>
112 <body>
113 <table>
114 <tr>
115 <?php
116 $sel = "SELECT * FROM `insertdeleteedittable`
117 $qrydisplay = mysqli_query($connect, $sel);
118 while($row = mysqli_fetch_array($qrydisplay))
119 $id = $row&#91;'id'&#93;;
120 $firstname = $row&#91;'firstname'&#93;;
121 $lastname = $row&#91;'lastname'&#93;;
122 $email = $row&#91;'email'&#93;;
123 echo "<tr><td>".$id."</td><td>".$firstname."
124 }
125 ?>
126 </tr>
127 </table>
128 </body>
129 </html>
130
131 edit.php
132
133 <?php
134 include("db.php");
135 $getid = $_GET&#91;'edit'&#93;;
136 $seledittwo = "SELECT * FROM `insertdeleteedi
137 $qry = mysqli_query($connect, $seledittwo);
138 $selassoc = mysqli_fetch_assoc($qry);
139 $id = $selassoc&#91;'id'&#93;;
140 $firstname = $selassoc&#91;'firstname'&#93;;
141 $lastname = $selassoc&#91;'lastname'&#93;;
142
PDFmyURL easily turns web pages and even entire websites into PDF!
143 $email = $selassoc&#91;'email'&#93;;
144 if(isset($_POST&#91;'updateedit'&#93;)) {
145 $upid = $_POST&#91;'upid'&#93;;
146 $upfirstname = $_POST&#91;'upfirstname'&#93
147 $uplastname = $_POST&#91;'uplastname'&#93;;
148 $upemail = $_POST&#91;'upemail'&#93;;
149
150
151 $seleditt = "UPDATE `insertdeleteedittable`
152 $qry = mysqli_query($connect,$seleditt);
153 if($qry) {
154 header("location: display.php");
155 }
156 }
157
158 //$seledit = "UPDATE `insertdeleteedittable`
159
160 ?>
161
162 <!DOCTYPE html>
163 <html>
164 <head>
165 <title></title>
166 </head>
167 <body>
168 <form method="POST" action="">
169 <input type="text" name="upid" value="<?ph
170 <input type="text" name="upfirstname" value=
171 <input type="text" name="uplastname" value="
172 <input type="text" name="upemail" value="<?p
173 <input type="submit" name="updateedit" value
174 </form>
175 </body>
176 </html>
177
178 delete.php
179
180
181 <?php
182 include("db.php");
183 $getid = $_GET&#91;'deleteid'&#93;;
184 $sel = "DELETE FROM `insertdeleteedittable` W
185 $qry = mysqli_query($connect, $sel);
186 if($qry) {
187 header("location: insertdeleteedit.php");
}

?>

PDFmyURL easily turns web pages and even entire websites into PDF!
How To Insert, Delete, Edit, Update And Select Data From Mysql Database Using Php, Sql, Html
And Css Tutorial

How To Insert, Delete, Edit, Update And Select Data From Mysql Database Using Php, Sql, Html
And Css Tutorial

PDFmyURL easily turns web pages and even entire websites into PDF!
How To Insert, Delete, Edit, Update And Select Data From Mysql Database Using Php, Sql, Html
And Css Tutorial

How To Insert, Delete, Edit, Update And Select Data From Mysql Database Using Php, Sql, Html
And Css Tutorial

How To Insert, Delete, Edit, Update And Select Data From Mysql Database Using Php, Sql, Html
And Css Tutorial

PDFmyURL easily turns web pages and even entire websites into PDF!
How To Insert, Delete, Edit, Update And Select Data From Mysql Database Using Php, Sql, Html
And Css Tutorial

Published by admin

View all posts by admin

Prev
How To Populate Html Table With
Data From Mysql Database Using
Php,Sql And Html Tutorial

Leave a Reply
Your email address will not be published. Required fields are marked *

Comment

PDFmyURL easily turns web pages and even entire websites into PDF!
Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.

POST COMMENT

© Copyright 2019 – Maurice Muteti


Allium Theme by TemplateLens ⋅ Powered by WordPress

PDFmyURL easily turns web pages and even entire websites into PDF!

You might also like