Jump to content

Zany

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Zany

  1. <?php include "connection.php"; ?> <html lang="en"> <head> <title>belgicaAct2_Add/Edit/Delete/View</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body <div class="container"> <div class="col-lg-4"> <h2>Course & Learning Management System</h2> <h2>Add/Edit/Delete/View</h2> <form action="" name="form1" method="post"> <div class="form-group"> <label for="email">firstname</label> <input type="text" class="form-control" id="firstname" placeholder="Enter firstname" name="firstname"> </div> <div class="form-group"> <label for="pwd">lastname</label> <input type="text" class="form-control" id="lastname" placeholder="Enter lastname" name="lastname"> </div> <div class="form-group"> <label for="pwd">email</label> <input type="text" class="form-control" id="email" placeholder="Enter email" name="email"> </div> <div class="form-group"> <label for="pwd">contact</label> <input type="text" class="form-control" id="contact" placeholder="Enter contact" name="contact"> </div> <button type="submit" name="insert" class="btn btn-default">Insert</button> <button type="submit" name="update" class="btn btn-default">Update</button> <button type="submit" name="delete" class="btn btn-default">Delete</button> </form> </div> </div> <div class="col-lg-12"> <table class="table table-bordered"> <thead> <tr> <th>#</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Contact</th> <th>Edit</th> <th>Delete</th> </tr> </thead> <tbody> <?php $result=mysqli_query($link,"select * from table1"); while($row=mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>"; echo $row["id"]; echo "</td>"; echo "<td>"; echo $row["firstname"]; echo "</td>"; echo "<td>"; echo $row["lastname"]; echo "</td>"; echo "<td>"; echo $row["email"]; echo "</td>"; echo "<td>"; echo $row["contact"]; echo "</td>"; echo "<td>"; ?> <a href="edit.php?id=<?php echo $row["id"]; ?> "><button type="button" class="btn btn-success">Edit</button></a> <?php echo "</td>"; echo "<td>"; ?> <a href="delete.php?id=<?php echo $row["id"]; ?> "><button type="button" class="btn btn-danger">Delete</button></a> <?php echo "</td>"; echo "</tr>"; } ?> </tbody> </table> </div> </body> <?php if(isset($_POST["insert"])) { mysqli_query($link,"insert into table1 values(NULL,'$_POST[firstname]','$_POST[lastname]','$_POST','$_POST[contact]')"); ?> <script type="text/javascript"> window.location.href=window.location.href; </script> <?php } if(isset($_POST["delete"])) { mysqli_query($link, "delete from table1 where firstname='$_POST[firstname]'") or die(mysqli_error($link)); ?> <script type="text/javascript"> window.location.href=window.location.href; </script> <?php } if(isset($_POST["update"])) { mysqli_query($link, "update table1 set firstname='$_POST[lastname]' where firstname='$_POST[firstname]'") or die(mysqli_error($link)); ?> <script type="text/javascript"> window.location.href=window.location.href; </script> <?php } ?> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.