Loading...
start the course

Learn PHP

Codes and notes

INSERT DATA INTO TABLE
Back Next

you can delete data from database syntax
<?php
$sql = "DELETE FROM users WHERE id=3";
? >

Back Next

Code editor

    <!DOCTYPE html>
    <html>
    <body>

    <?php
    
    # if statement in php
    
    
        $conn 
        
        = mysqli_connect("localhost","root","","firstTable");
        
   
        
        $sql 
        
        = "DELETE FROM users WHERE id=3";
        
              
        if  
            ($conn->query($sql) === TRUE) {
             
        
            
        echo
             
            
            "Data deleted successfully";
          
        
        
            }else {
         
        
        echo
             
        
        "Error deleting into table: " . $conn->error;
         
        
            
        $conn->close(); 
        }
    
              

        
    ?>

    </body>
    </html>
    

Output