crud edit button only showing last variable

27
March 15, 2019, at 00:20 AM

I am creating my first php app and running into an issue on how I should try and edit a sql entry. I was planning on trying to get a modal window to pop up in order to edit.

currently I am echoing a edit button after performing a while loop but when I try and select the edit button, my variables are my very last iteration of the loop.

Do I need to assign an ID or something to my edit and delete button.

<?php            
$sql = "SELECT id, image, name, score, points FROM teams";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0) {

    while($row = mysqli_fetch_assoc($result)){
        $teams_id = $row["id"];
        $teams_image = $row["image"];
        $teams_name = $row["name"];
        $teams_score = $row["score"];
        $teams_points = $row["points"];
    //    echo "id: " . $teams_id . " image path: " . $teams_image . " name: " . $teams_name . " score " . $teams_score . " points " . $teams_points . "</br>"; 
        echo "<div class='row'>";
        echo "<div class='row oval'>";
        echo "<div class='col-4 flag {$teams_image}'>";
        echo "</div>";
        echo "<div class='col-8 text'>";
        echo "<p>{$teams_name}</p>";
        echo "</div>";
        echo "</div>";

        // edit and delete button 
        echo "<button class='btn btn-outline-light btn-sm ml-4 align-self-center' data-toggle='modal' data-target='#editModal'>edit</button>";
        echo "<button class='btn btn-outline-light btn-sm ml-1 align-self-center'>delete</button>";
        echo "</div>";
    } 
}else {
    echo "No teams added yet";
}
?>
READ ALSO
String type casing in php, is it string or String?

String type casing in php, is it string or String?

What is the official name for the php string type?

19
add url parameters to $_GET variable with separated commas issue

add url parameters to $_GET variable with separated commas issue

This is my function, I simply want to output a link like this:

41
How to get current server avaible quota to send emails with PHP

How to get current server avaible quota to send emails with PHP

im in a development of an website that needs to send massive emails to their usersI have done the PHP script to send emails using PHPMailer and its ok, but the server has a limit by hour to send emails

45
.htaccess file is not working properly on Godaddy server

.htaccess file is not working properly on Godaddy server

I have hosted my folder on godaddy linux cpanelWordpress files are in inside /public_html/tma

52