Create the first index.php file
copy and paste this code
<?php
include('update.php');
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$update = true;
$record = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
if (count($record) == 1 ) {
$n = mysqli_fetch_array($record);
$name = $n['name'];
$address = $n['address'];
$id = $n['id'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>profile update page</title>
</head>
<body>
<?php if (isset($_SESSION['message'])): ?>
<div class="msg">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?php endif ?>
<table>
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php while ($row = mysqli_fetch_array($results)) { ?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['address']; ?></td>
<td>
<a class = "udatebutton" href="index.php?edit=<?php echo $row['id']; ?>" class="udatebutton" >Edit</a>
</td>
<td>
<a class = "deletebutton" href="update.php?del=<?php echo $row['id']; ?>" class="deletebutton">Delete</a>
</td>
</tr>
<?php } ?>
</table>
<form method="post" action="update.php" >
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="input-group">
<label>Name</label>
<input type="text" name="name" value="<?php echo $name; ?>">
</div>
<div class="input-group">
<label>Address</label>
<input type="text" name="address" value="<?php echo $address; ?>"
</div>
<div class="input-group">
<?php if ($update == true): ?>
<button class="btn" type="submit" name="update" style="background: #556B2F;" >update</button>
<?php else: ?>
<button class="btn" type="submit" name="save" >Save</button>
<?php endif ?>
</div>
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------------------
Create style.css file
<style>
body {
font-size: 19px;
}
table{
width: 50%;
margin: 30px auto;
border-collapse: collapse;
text-align: left;
}
tr {
border-bottom: 1px solid #cbcbcb;
}
th, td{
border: none;
height: 30px;
padding: 2px;
}
tr:hover {
background: #ffff;
}
form {
width: 45%;
margin: 50px auto;
text-align: left;
padding: 20px;
border: 1px solid #bbbbbb;
border-radius: 5px;
}
.input-group {
margin: 10px 0px 10px 0px;
}
.input-group label {
display: block;
text-align: left;
margin: 3px;
}
.input-group input {
height: 30px;
width: 93%;
padding: 5px 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid gray;
}
updatebutton {
padding: 10px;
font-size: 15px;
color: white;
background: #5F9EA0;
border: none;
border-radius: 5px;
}
.editbutton {
text-decoration: none;
padding: 2px 5px;
background: #2E8B57;
color: white;
border-radius: 3px;
}
.deletbutton{
text-decoration: none;
padding: 2px 5px;
color: white;
border-radius: 3px;
background: #800000;
}
.msg {
margin: 30px auto;
padding: 10px;
border-radius: 5px;
color: #3c763d;
background: #dff0d8;
border: 1px solid #3c763d;
width: 50%;
text-align: center;
}
</style>
---------------------------------------------------------------------------------------------------------------
ADD This Code <head> tag in index.php
<link rel="stylesheet" type="text/css" href="addfilename">
----------------------------------------------------------------------------------------------------------------------
Create update.php file
copy paste php code
<?php
session_start();
$db = mysqli_connect('localhost', 'root', '', 'crud'); // connection database code
$name = "";
$address = "";
$id = "0";
$update = false;
if (isset($_POST['save'])) {
$name = $_POST['name'];
$address = $_POST['address'];
mysqli_query($db, "INSERT INTO info (name, address) VALUES ('$name', '$address')");
$_SESSION['message'] = "Address saved";
header('location: index.php');
}
if (isset($_POST['update']))
{
$name = $_POST['name'];
$address = $_POST['address'];
$id = $_POST['id'];
$sql = "UPDATE info SET name='".$name."', address='".$address."' WHERE id='".$id."' ";
mysqli_query($db, $sql );
$_SESSION['message'] = "Address updated!";
header('location: index.php');
}
if (isset($_GET['del'])) {
$id = $_GET['del'];
mysqli_query($db, "DELETE FROM info WHERE id=$id");
$_SESSION['message'] = "Address deleted!";
header('location: index.php');
}
$results = mysqli_query($db, "SELECT * FROM info");
?>
Somebody necessarily help to make significantly posts
ReplyDeleteI'd state. That is the first time I frequented your web page and up to now?
I surprised with the research you made to make this actual publish extraordinary.
Magnificent process!
What's up i am kavin, its my first time to commenting
ReplyDeleteanyplace, when i read this paragraph i thought i could also create comment due to this
brilliant piece of writing.
Thank you for your post.
ReplyDeleteAsp.Net Training in Chennai | Best Dot Net Training in Chennai
Selenium Training in Chennai | Selenium Testing Training in Chennai
Testing Courses in Chennai | Software Testing Course in Chennai
Java Training Institute in Chennai | Core Java Training in Chennai | Java Course and Certification
PHP Course in Chennai | PHP Training Institute in Chennai | PHP Course and Certification
I visited various websites but the audio quality for audio songs current at this
ReplyDeleteweb page is in fact fabulous.
Wow, marvelous blog layout! How long have you been blogging for?
ReplyDeleteyou make blogging look easy. The overall look of your website
is excellent, as well as the content!
My relatives always say that I am killing my time here at net,
ReplyDeletehowever I know I am getting experience daily by reading such pleasant articles or
reviews.
I was wondering if you ever considered changing the page layout of your site?
ReplyDeleteIts very well written; I love what youve got to
say. But maybe you could a little more in the way of content so people could connect with it better.
Youve got an awful lot of text for only having one
or 2 pictures. Maybe you could space it out better?
Every weekend i used to go to see this web site,
ReplyDeletebecause i wish for enjoyment, as this this website conations genuinely fastidious funny material too.
Simply want to say your article is as astonishing. The clarity in your post is simply
ReplyDeletespectacular and i can assume you are an expert on this subject.
Well with your permission let me to grab your RSS feed to keep updated with forthcoming post.
Thanks a million and please continue the gratifying work.
We're a group of volunteers and opening a new scheme in our community.
ReplyDeleteYour site offered us with valuable info to work
on. You've done a formidable job and our whole community will be thankful to
you.
Link exchange is nothing else but it is just placing the other person's webpage link on your page at proper place and other person will also do same in support of you.
ReplyDeleteHey there would you mind letting me know which hosting company
ReplyDeleteyou're using? I've loaded your blog in 3 different browsers and I must say this blog loads
a lot quicker then most. Can you recommend a good internet
hosting provider at a honest price? Many thanks, I appreciate it!
I like the valuable info you provide in your articles. I'll bookmark your blog and
ReplyDeletecheck again here frequently. I'm quite certain I'll learn many new stuff right here!
Best of luck for the next!
I know this if off topic but I'm looking into starting my own weblog and was wondering what all is
ReplyDeleterequired to get setup? I'm assuming having a blog like yours would cost a pretty penny?
I'm not very internet savvy so I'm not 100% sure. Any recommendations or advice would be greatly appreciated.
Kudos
I do not even know how I ended up here, but I thought this post was great.
ReplyDeleteI don't know who you are but certainly you're going to a famous blogger if you are not already
;) Cheers!
Hello, i believe that i noticed you visited my website thus i got
ReplyDeletehere to return the desire?.I am attempting to find issues to enhance my website!I guess its adequate to
use some of your ideas!!
An impressive share! I've just forwarded this onto a coworker who
ReplyDeletehas been doing a little research on this. And he actually
ordered me dinner simply because I stumbled upon it for
him... lol. So allow me to reword this.... Thanks for the meal!!
But yeah, thanx for spending some time to talk about this issue here on your website.
Hello! This is kind of off topic but I need some help from
ReplyDeletean established blog. Is it hard to set up your own blog?
I'm not very techincal but I can figure things out pretty fast.
I'm thinking about creating my own but I'm not sure where to start.
Do you have any points or suggestions? Appreciate it
Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai
ReplyDeleteSpring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.
Spring Training in Chennai
The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training