从'table'中删除id ='selected record'?

I'm selecting records from a table with a Delete button in the echo line. I want to be able to delete the record when I click on the corresponding Delete button. This is my delete query to delete the selected record from the other query, but it won't work!

$querytwo = 'DELETE FROM paginas WHERE id= $_POST["id"]';   

I'm doing something wrong. What is it? Here is the full code.

    <?php

        include_once("config.php"); //this is the database connection
        $query = "SELECT * FROM paginas "; //selects from the table called paginas
        $result = mysqli_query($mysqli, $query);

            while($row = mysqli_fetch_assoc($result)) 
            {
            $pagetitle = $row['pagetitle'];
            $toevoeging = $row['toevoeging'];
            $message = $row['message'];

                echo '<article class="topcontent">
       <div class="mct">
        <h2>' . $pagetitle .'</h2>
       </div><br>
       <p class="post-info">'. $toevoeging . '</p>
       <p class="post-text"><br>'.$message.'</p>
      </article>
       <div class="deleteknop">
        <form method="post">';

   echo '<input type="hidden" name="id" value="'.$row['id'].'">
         <input name="delete" type="submit" value="Delete Now!">
        </form>
       </div>' ;
            }

        $querytwo = 'DELETE FROM paginas WHERE id= $_POST["id"]';

        if (isset($_POST['delete'])) //Deletes the query if 'delete' button is clicked

            {
                $resulttwo = $mysqli->query($querytwo);  
            }

            ?>

Got it working. I changed the line to $querytwo = "DELETE FROM paginas WHERE id= $_POST[id]"; It's functional. Although there was a warning notice saying “Notice: Undefined index” but I got rid of it thanks to error_reporting(0);

You need to use double quotes for variable interpolation to work. With single quotes, the exact string you see is what is getting sent as the database query, which is not a valid query. Something like this would actually substitute the value of the POST variable in the string:

$querytwo = "DELETE FROM paginas WHERE id = $_POST[id]"

However, interpolating variables directly into a query string is a bad idea as it can result in a SQL injection vulnerability. I would advise looking up parameterized queries.

You could just:

$querytwo = 'DELETE FROM `paginas` WHERE id= ' . $row['id'] . ' LIMIT 1'; 

you can use:

$querytwo = 'DELETE FROM paginas WHERE id= $_POST["id"]';

no need to use limit, you are using id for reference so it will delete one record.