You are on page 1of 7

button link

<td> <button class="btn-danger btn"> <a href="delete.php?id=<?php echo $res['id'];


?>" class="text-white"> Delete </a> </button> </td>
<td> <button class="btn-primary btn"> <a href="update.php?id=<?php echo
$res['id']; ?>" class="text-white"> Update </a> </button> </td>
<td> <button class="btn-success btn"> <a href="insert.php?id=<?php echo
$res['id']; ?>" class="text-white"> insert </a> </

display.php

<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, world!</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>

<div class="container">
<div class="col-lg-12">
<br><br>
<h1 class="text-success text-center" > Display Table Data </h1>
<br>

<table id="tabledata" class=" table table-striped table-hover table-bordered">

<tr class="bg-dark text-white text-center">

<th> Id </th>
<th> Username </th>
<th> Password </th>
<th> Delete </th>
<th> Update </th>
<th> insert </th>

</tr >

<?php

include 'conn.php';
$q = "select * from curdtable ";

$query = mysqli_query($con,$q);

while($res = mysqli_fetch_array($query)){
?>
<tr class="text-center">
<td> <?php echo $res['id']; ?> </td>
<td> <?php echo $res['username']; ?> </td>
<td> <?php echo $res['password']; ?> </td>
<td> <button class="btn-danger btn"> <a href="delete.php?id=<?php echo $res['id'];
?>" class="text-white"> Delete </a> </button> </td>
<td> <button class="btn-primary btn"> <a href="update.php?id=<?php echo
$res['id']; ?>" class="text-white"> Update </a> </button> </td>
<td> <button class="btn-success btn"> <a href="insert.php?id=<?php echo
$res['id']; ?>" class="text-white"> insert </a> </button> </td>

</tr>

<?php
}
?>

</table>

</div>
</div>

<script type="text/javascript">

$(document).ready(function(){
$('#tabledata').DataTable();
})

</script>

<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

insert.php
<?php

include 'conn.php';

if(isset($_POST['done'])){

$username = $_POST['username'];
$password = $_POST['password'];
$q = " INSERT INTO `curdtable`(`username`, `password`) VALUES ( '$username',
'$password' )";

$query = mysqli_query($con,$q);

header('location:display.php');
}
?>

<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, world!</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>

<div class="col-lg-6 m-auto">

<form method="post">

<br><br><div class="card">

<div class="card-header bg-dark">


<h1 class="text-white text-center"> Insert Operation </h1>
</div><br>

<label> Username: </label>


<input type="text" name="username" class="form-control"> <br>

<label> Password: </label>


<input type="text" name="password" class="form-control"> <br>

<button class="btn btn-success" type="submit" name="done"> Submit </button><br>

</div>
</form>
</div>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

update.php

<?php

include 'conn.php';

if(isset($_POST['done'])){

$id = $_GET['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$q = " update curdtable set id=$id, username='$username', password='$password'
where id=$id ";

$query = mysqli_query($con,$q);

header('location:display.php');
}

?>

<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, world!</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>

<div class="col-lg-6 m-auto">

<form method="post">

<br><br><div class="card">

<div class="card-header bg-dark">


<h1 class="text-white text-center"> Update Operation </h1>
</div><br>
<label> Username: </label>
<input type="text" name="username" class="form-control"> <br>

<label> Password: </label>


<input type="text" name="password" class="form-control"> <br>

<button class="btn btn-success" type="submit" name="done"> Submit </button><br>

</div>
</form>
</div>

<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

delete.php

<?php

include 'conn.php';

$id = $_GET['id'];

$q = " DELETE FROM `curdtable` WHERE id = $id ";

mysqli_query($con, $q);

header('location:display.php');

?>

<?php
include 'conn.php';

if(isset($_POST['done'])){

$username = $_POST['username'];
$password = $_POST['password'];
$section = $_POST['section'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$q = " INSERT INTO `students`(`username`, `password`, `section`, `phone`,
`address` ) VALUES ( '$username', '$password', '$section', '$phone', '$address' )";

$query = mysqli_query($con,$q);

header('location:display.php');
}
?>

<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, world!</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>

<div class="col-lg-6 m-auto">

<form method="post">

<br><br><div class="card">

<div class="card-header bg-dark">


<h1 class="text-white text-center"> Insert Operation </h1>
</div><br>

<label> Username: </label>


<input type="text" name="username" class="form-control"> <br>

<label> Password: </label>


<input type="text" name="password" class="form-control"> <br>

<label> section: </label>


<input type="text" name="section" class="form-control"> <br>

<label> phone: </label>


<input type="text" name="phone" class="form-control"> <br>
<label> address: </label>
<input type="text" name="address" class="form-control"> <br>

<button class="btn btn-success" type="submit" name="done"> Submit </button><br>

</div>
</form>
</div>

<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

You might also like