Jump to content

Removing rows from table on website

Tracomaster

Any of you guys have knowledge about PHP and databases and stuff?

So I made this website and you can enter stuff into one table but some ass decided to spam it and I want to remove a couple of rows. 
Yet I have no clue where to put the delete query. I only have the website and the files in my filezilla. No mysqladmin or something...
help?

 

 

My code attached below for my php. I want to remove 1 or two certain rows from "klanten". This is within my html code.

 

<?php
 
$db = new mysqli('serverIP', 'username', 'password', 'username+db');
    if($db->connect_errno > 0){
    die('Unable to connect to database [' . $db->connect_error . ']');
    }  
 
     $sql = <<<SQL
    SELECT *
    FROM `Klanten`
    
SQL;
if(!$result = $db->query($sql)){
    die('There was an error running the query [' . $db->error . ']');
}
echo '<p><B>Deze hebben bij ons gekoopt</B></p>';
echo '<table>
    <tr>
    <th>KlantenID</th>
    <th>Namen</th>
    <th>Leeftijd</th>
    <th>Spammail</th>
    <th>Leefplaats</th>
    <th>RL Spammail</th>
    <th>Doekoepaasmethode</th>
    
     </tr>';
     
while($row = $result->fetch_assoc()){
    echo '<tr bgcolor = "#D94D3B">';
    echo '<td>' . $row['KlantenID'] . '</td>';
    echo '<td>' . $row['Klanten'] . '</td>';
    echo '<td>' . $row['Leeftijd'] . '</td>';
    echo '<td>' . $row['Email'] . '</td>';
    echo '<td>' . $row['Stad'] . '</td>';
    echo '<td>' . $row['Postcode'] . '</td>';
    echo '<td>' . $row['Betaalmethode'] . '</td>';
    
    echo '</tr>';
    
}    
 
 echo '</table>';
 
 $mysqli->close();
?>
Link to comment
Share on other sites

Link to post
Share on other sites

If you don't have access to a database admin tool, you can create a new page (or add the code to the existing page) to simply remove the records you want... e.g.

 $sql = <<<SQL    DELETE FROM `Klanten` WHERE KlantenID = {ID NUMBER}SQL;$db->query($sql);
Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×