我试图在我的SQL数据库中获取id的值,并将其作为我的复选框的值插入

Im trying to get the value of id in my sql database and insert it as the value of my checkbox.

while( $result = mysql_fetch_object( $requete ) ) {
            $temp = $temp + 1;
            echo(" <form><div align =\"center\">".$result->nom." ".$result->prenom."<input type='checkbox' name='sel[]' value='$temp'>");
            }
        echo("<br><br><input type='button' onClick='confirme($temp)' value='Supprimer'></form>");

$temp should be the value of the id in sql, and the function confirme() should run with the value of the id.

<?php
while( $result = mysql_fetch_assoc($requete)) {
                    $temp++;
                    echo "<form><div align ='center'> $result[nom] $result[prenom] <input type='checkbox' name='sel[]' value='$temp'>";
                    }
                echo "<br><br><input type='button' onClick='confirme($temp)' value='Supprimer'></form>";
?>

Try this

You forgot to concatenate the $temp variable in your echo and your second echo is outside the loop:

while( $result = mysql_fetch_object( $requete ) ) {
    $temp = $temp+1;
    echo(" <form><div align =\"center\">".$result->nom." ".$result->prenom."<input type='checkbox' name='sel[]' value='".$temp."'>");
    echo("<br><br><input type='button' onClick='confirme(".$temp.")' value='Supprimer'></form>");
}

But you say that you want the id, and $temp is definitely not the id, but just a counter which may or may not coincide with and id on the database. you have to do the same as you did with the other columns and your code would end up like:

while( $result = mysql_fetch_object( $requete ) ) {
    $temp = $result->id # assuming the column you want is actually named "id"
    echo(" <form><div align =\"center\">".$result->nom." ".$result->prenom."<input type='checkbox' name='sel[]' value='".$temp."'>");
    echo("<br><br><input type='button' onClick='confirme(".$temp.")' value='Supprimer'></form>");
}