11 PHP application to delete Rows in a Table Program PHP- record

 

Note:- four programs 

01- index page,

02-connecting database,

03-editing in a table,

04-update table .

save--index.php

 program:-01

<!DOCTYPE html>
<html>
<head>
<title>Basic MySQLi Commands</title>
</head>
<body>
    <div>
        <form method="POST" action="add.php">
            <label>UserId:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="userid"><br>
            <label>Firstname:</label><input type="text" name="firstname"><br>
            <label>Lastname:</label><input type="text" name="lastname"><br>
            <label>E_Mail:&nbsp;&nbsp;&nbsp;</label><input type="text" name="E_mail"><br>
            <input type="submit" name="add">
        </form>
    </div>
    <br>
    <div>
        <table border="1">
            <thead>
                <th>UserId&nbsp;&nbsp;&nbsp;</th>
                <th>Firstname</th>
                <th>Lastname</th>
                <th>E-Mail&nbsp;&nbsp;&nbsp;</th>
                <th></th>               
            </thead>
            <tbody>
                <?php
                    include('conn.php');
                    $query=mysqli_query($conn,"select * from `user`");
                    while($row=mysqli_fetch_array($query)){
                        ?>
                        <tr>
                            <td><?php echo $row['userid']; ?></td>
                            <td><?php echo $row['firstname']; ?></td>
                            <td><?php echo $row['lastname']; ?></td>
                            <td><?php echo $row['E_mail']; ?></td>
                            <td>
                                <a href="edit.php?userid=<?php echo $row['userid']; ?>">Edit</a>
                                <a href="delete.php?userid=<?php echo $row['userid']; ?>">Delete</a>
                            </td>
                        </tr>
                        <?php
                    }
                ?>
            </tbody>
        </table>
    </div>
</body>
</html>

save--conn.php

 program:-02

<?php
$conn = mysqli_connect("localhost","root","","ibm_database");
 
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?> 

save--delete.php

 program:-03

<?php
    $userid=$_GET['userid'];
    include('conn.php');
    mysqli_query($conn,"delete from `user` where userid='$userid'");
    header('location:index.php');
?>

 

save--update.php

 program:-04

<?php
    include('conn.php');
    $userid=$_GET['userid'];
 
    $userid=$_POST['userid'];
    $firstname=$_POST['firstname'];
    $lastname=$_POST['lastname'];
    $E_mail=$_POST['E_mail'];
 
    mysqli_query($conn,"update `user` set userid='$userid', firstname='$firstname', lastname='$lastname', E_mail='$E_mail'  where userid='$userid'");
    header('location:index.php');
?>

 

output:-01

preview-----output change to edit userid-106.


 

 

 

Comments

Popular posts from this blog

digital marketing ppt-u1

SOFTWARE

cn lab

Computer Operations and Performing - D L Unit-1-1

DBMS Degree Lab Records

DS-Record-mca-04) write a program for evaluating a given postfix expression using stack.

Java unit-1 history , C++ vs Java , java environment

Access the Internet to Browse Infromation & E-Mail Operation- D L Unit-2-1

OAT-Record-01) Visiting card

java program structure,java Tokens, keywords,