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 118991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:34:56+00:00 2026-05-11T03:34:56+00:00

I would like to know the best way to delete records from a live

  • 0

I would like to know the best way to delete records from a live database and refresh the page instantly. At the moment I am using ajax, with the following javascript method:

function deleterec(layer, pk) {    url = 'get_records.php?cmd=deleterec&pk='+pk+'&sid='+Math.random();    update('Layer2', url); } 

if cmd=deleterec on the php page, a delete is done where the primary key = pk. This works fine as in the record is deleted, however the page is not updated.

My update method is pretty simple:

function update(layer, url) {     var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere      if(xmlHttp==null) {         alert('Your browser is not supported?');     }      xmlHttp.onreadystatechange = function() {         if(xmlHttp.readyState==4 || xmlHttp.readyState=='complete') {             document.getElementById(layer).innerHTML=xmlHttp.responseText;         } else if (xmlHttp.readyState==1 || xmlHttp.readyState=='loading') {             document.getElementById(layer).innerHTML='loading';         }         //etc     }      xmlHttp.open('GET',url,true);     xmlHttp.send(null); } 

how to delete or alter record, and upate the page.

At the moment my ajax framework works by passing data to a javascript update method, which works fine for selecting different queries to display in different layers.

I want to add the functionality to delete, or alter the records in a certain way.

I am wondering if it is possible when clicking a link to execute a query and then call my update method and refesh tge page. Is there any easy way to do this given my update methods?

I would like to avoid rewriting my update method if possible.

WOuld the simplest method be to have the php page(only in the layer) reload itself after executing a mysql query?

Or to make a new ‘alterstatus’ method, which would pass delete or watch as a paramter, and have the php execute a query accordingly and then update the page?

edit: The links are generated like so. deleterec would be called from an additional link generated.

{

$pk = $row['ARTICLE_NO'];  echo '<tr>' . '\n';       echo '<td><a href='#' onclick='updateByPk(\'Layer2\', \'' . $pk . '\')'>'.$row['USERNAME'].'</a></td>' . '\n';   echo '<td><a href='#' onclick='updateByPk(\'Layer2\', \'' . $pk . '\')'>'.$row['shortDate'].'</a></td>' . '\n';   echo '<td><a href='#' onclick='updateByPk(\'Layer2\', \'' . $pk . '\')'>'.$row['ARTICLE_NAME'].'</a></td>' . '\n';    echo '<td><a href='#' onclick='deleteRec(\'Layer2\', \'' . $pk . '\')'>'.$row['ARTICLE_NAME'].'</a></td>' . '\n';   echo '</tr>' . '\n';  

}

edit: the update method can not be modified, as it is used by the updateByPk and updateBypg methods which need a layer.

  • 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. 2026-05-11T03:34:57+00:00Added an answer on May 11, 2026 at 3:34 am

    Without digging too much into your code specifics, I don’t know of any way to update/delete from the server side DB without doing a round trip (either AJAX or a page navigation). I would however recommend using a JavaScript framework (like jQuery, or something else) to handle the AJAX and DOM manipulations. That should, in theory, alleviate any cross-browser troubleshooting on the client side of thinbs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know what's the best way to organize my php project
I would like to know What is the best way to include 3rd party
I would like to know how to use Queue in the best functional way.
I would like to know what is the best, fastest and easiest way to
I would like to know the best way to check one table of data,
I would like to know the best way to profile app code on OS
I would like to know the best way to implement paging in queries. Currently,
I would like to know the best way to display flash messages in Kohana
I would like to know, what would be the best way to manage a
I would like to know the best way to work with packed files in

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.