Saturday, December 14, 2024
HomePHPMethods to delete information from PostgreSQL utilizing PHP

Methods to delete information from PostgreSQL utilizing PHP


<?php include_once(‘dbcon.php’);

//Code for deletion

if(isset($_GET[‘deleteid’]))

{

$rid=intval($_GET[‘deleteid’]);

$sql=pg_query($conn,“delete from tblemployee the place ID=$rid”);

echo “<script>alert(‘Information deleted’);</script>”;

echo “<script>window.location.href=”https://phpgurukul.com/how-to-delete-data-from-postgresql-using-php/learn.php”</script>”;    

} ?>

 

<!DOCTYPE html>

<html lang=“en”>

<head>

<meta charset=“utf-8”>

<meta identify=“viewport” content material=“width=device-width, initial-scale=1, shrink-to-fit=no”>

<title>Fetch Information from PostgreSQL utilizing PHP</title>

<hyperlink rel=“stylesheet” href=“https://fonts.googleapis.com/css?household=Roboto”>

<hyperlink rel=“stylesheet” href=“https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css”>

<hyperlink rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css”>

<script src=“https://code.jquery.com/jquery-3.5.1.min.js”></script>

<script src=“https://cdn.jsdelivr.web/npm/popper.js@1.16.0/dist/umd/popper.min.js”></script>

<script src=“https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js”></script>

<model>

physique {

    shade: #666;

    background: #f5f5f5;

    font-family: ‘Roboto’, sans-serif;

}

.table-responsive {

margin: 30px 0;

}

desk.desk tr th, desk.desk tr td {

    border-color: #e9e9e9;

}

desk.table-striped tbody tr:nth-of-type(odd) {

    background-color: #fcfcfc;

}

.table-wrapper {

    min-width: 1000px;

    background: #fff;

    padding: 20px;

    box-shadow: 0 1px 1px rgba(0,0,0,.05);

}

.pagination {

    margin: 10px 0 5px;

}

.pagination li a {

    border: none;

    min-width: 30px;

    min-height: 30px;

    shade: #999;

    margin: 0 2px;

    line-height: 30px;

    border-radius: 4px !vital;

    text-align: heart;

    padding: 0;

}

.pagination li a:hover {

    shade: #666;

}

.pagination li.lively a, .pagination li.lively a.page-link {

    background: #59bdb3;

}

.pagination li.lively a:hover {        

    background: #45aba0;

}

.pagination li:first-child a, .pagination li:last-child a {

    padding: 0 10px;

}

.pagination li.disabled a {

    shade: #ccc;

}

.pagination li i {

    font-size: 17px;

    place: relative;

    prime: 1px;

    margin: 0 2px;

}

</model>

</head>

<physique>

<div class=“container-xl”>

    <div class=“table-responsive”>

        <div class=“table-wrapper”>

            <a href=“index.php” class=“btn btn-info”>Add File</a>

            <desk class=“desk table-striped mt-4”>

                <thead>

                    <tr>

                        <th>#</th>

                        <th>Identify</th>

                        <th>E-mail Id</th>

                        <th>Cell No</th>

                        <th>Division</th>

                        <th>Creation Date</th>

                        <th>Motion</th>

                    </tr>

                </thead>

                <tbody>

<?php $question= pg_query($conn,“choose * from tblemployee”);

$cnt=1;

whereas($row=pg_fetch_array($question)){

?>

 

                    <tr>

                        <td><?php echo $cnt;?></td>

                        <td><?php echo $row[’empname’];?></td>

                        <td><?php echo $row[’empemailid’];?></td>

                        <td><?php echo $row[’empmobileno’];?></td>

                        <td><?php echo $row[’empdepartment’];?></td>

                        <td><?php echo $row[‘creationdate’];?></td>

                        <td><a href=“edit.php?id=<?php echo $row[‘id’];?> class=“btn btn-info btn-sm”>Edit</a>

<a href=“learn.php?deleteid=<?php echo $row[‘id’];?> class=“btn btn-danger btn-sm”>delete</a>

 

                        </td>

                    </tr>

                <?php $cnt++;} ?>

                    

                </tbody>

            </desk>

      

        </div>

    </div>

</div>    

</physique>

</html>

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments