Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7950509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:17:43+00:00 2026-06-04T02:17:43+00:00

I have problems with deleting a record from the screen using MSQLI. Here you

  • 0

I have problems with deleting a record from the screen using MSQLI.
Here you can see the code i’m using.

<?php
        include_once("assets/classes/connection.php");
        include_once("assets/classes/article.class.php");
        while($test = $allArticles->fetch_assoc())
            {
                if($test['titel']=="")
                {
                    echo "<div class='zonderfoto'>";
                    echo "<h5>"."geen titel hier, aparte opmaak geslaagd" . "<br /></h1>";
                    echo "<p>" . $test['article'] . "</p>";

                    echo "<input type='submit' name='verwijderee' value='verwijder'>";

                    echo "</div>";
                }
                else
                {
                    echo "<div class='metfoto'>";
                    echo "<h1>".$test['titel'] . "<br /></h1>";
                    echo "<p>" . $test['article'] . "</p>";
                    echo "<form method='post' action=''>";
                    echo "<input type='submit' name='verwijder' value='verwijder'>";
                    echo "</form>";
                    echo "<h1>".$test['id']."</h1>";
                    echo "</div>";


                }
            }
        $vArticle = new Article;
        $vArticle -> Key = $test['id'];
        if (isset($_POST['verwijder']))
        {
            $vArticle -> deleteArticle();
            echo ("shit");
        }
        ?>

I’m using a while function to print all the DB records on the screen. The if function is just a function to give some design with css so nothing more. With the delete button i want to delete the record from the screen. With the $test[‘id’] variabele you receive the ID of the record in the DB

Ok here is my code from the class.

public function deleteArticle()
{
    include("connection.php");
    $sSql = "DELETE FROM tblArticles WHERE id = '".$this->m_sKey."'";

        if (!$mysqli -> query($sSql))
        {
            throw new Exception("Something went wrong");
        }
}

EDIT

There is something wrong with the key, i replaced the where statement with title =””, so i deleted one title in the database, and when i click on delete then, he delete one row, but this is not happening at runtime. so i click delete, one row deleted, BUT the content only dissapear with a page refresh. The solution is using ajax?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:17:45+00:00Added an answer on June 4, 2026 at 2:17 am
    public function deleteArticle()
    {
        include("connection.php");
        $sSql = "DELETE FROM tblArticles WHERE id = '".$this->m_sKey."'";
        $mysqli->query($sSql);
        $aff_rows = $mysqli->affected_rows;
        if ($aff_rows){
            print("Affected rows (DELETE): %d\n", $aff_rows);
        }
        else{
            print("Nothong Happend ?");
            if ($err = $mysqli->error){
                  print("Error: %s\n", $err);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with deleting a record from my SQLite3 database: conn =
Ever since deleting the original settings.settings file I have had endless problems getting the
I have problems with my keyup binding when cloning an element. Here's the scenario:
I have problems with following code: http://lisper.ru/apps/format/96 The problem is in normalize function, which
I have problems building a binary tree from the bottom up. THe input of
I am experiencing issues with deleting a row / data record from an SQLite
I have some problems with Eclipse server adapter for Glassfish 3.1. I am using
I'm using Play Framework, and have the following code: import org.hibernate.exception.ConstraintViolationException; ... public class
I have some problems with deleting object. I am getting the following error: [Test.Item#ab9a9869-b2c1-4262-8d33-9dd9010abd96][SQL:
I have a Telerik Ajax bound grid containing a Html.ActionLink for deleting a record.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.