mercredi 16 août 2017

Buttons in Table using PHP/SQL Loop

I have this piece of code:

<?php $res = $conn->query("SELECT * FROM users");
    //If the result of the query has more than 0 rows (1 or more) continue to the loop
    if(mysqli_num_rows($res) >0){
        //Loop to organise the data
        while($row = mysqli_fetch_array($res)){
            if($row['permission'] == "2"){
                 $perms = '<span class="label label-danger">Administrator</span>';
            } elseif($row['permission'] == "1"){
                 $perms = '<span class="label label-success">Registered User</span>';
            } else {
                 $perms = '<span class="label label-warning">Awaiting Approval</span>';
            }


            //Return the table data
            echo "<tr><td>" . $row['firstname'] . "</td><td>" . $row['surname'] . "</td><td>" . $row['email'] . "</td><td>" . $row['username'] . "</td><td>" . $row['telephone'] . "</td><td>" . $perms . "</td>";

        }
   }?>

What I want is to add a button in a new column for every row that will activate a piece of code to delete the record in the db.

http://ift.tt/2waLspK

was wondering if someone could assist or point me in the right direction on how to do this. Eventually, there will be a delete button and an approve button that will activate different pieces of SQL code located in the same file. Thanks




Aucun commentaire:

Enregistrer un commentaire