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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:42:32+00:00 2026-06-12T15:42:32+00:00

I have made a js function to remove data from a database using ajax.

  • 0

I have made a js function to remove data from a database using ajax. its very basic but i want to get it to work before i add anything else the function is below:

function removeAd(ad_id) {

    $.post('remove.php', {id: ad_id});

};

I use php to build a page and create links that use this function:

<ul id='categoryorder'>

<?php while ($item = mysqli_fetch_array($r)) { ?>

<li id="advert_<?php echo $item['display_id'] ?>"><div class="<?php echo $item['ad_type']?>"><a href="javascript:removeAd('<?php echo $item['display_id'] ?>')" >Remove</a></div></li>

<?php } ?> 

</ul>

it builds the page fine and creates remove links within divs that have a href of javascript:removeAd(id) with the id being the id that relates to that div in a database eg:

<li id="advert_5"><div class="banner"><a href="javascript:removeAd('5')" >Remove</a></div></li>

finally this should send to the remove.php script which actually removes from the database the entry with that ID

<?php

require ('Mysql_Connect.php');

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    $q = "DELETE FROM st_display WHERE display_id = {$_POST['id']}";
    $r = @mysqli_query ($dbc, $q);

}

?>

I am very new to this so im quite prepared to be told that im making a stupid mistake or that this will never work! but any help will be much appreciated.

  • 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-12T15:42:33+00:00Added an answer on June 12, 2026 at 3:42 pm

    Your query is perfect for a good SQL injection.
    But that’s not the importance here, if you try to do echo $q does it return something ?
    Do a console.log(ad_id); before your $.post to see if you send the data as well.

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

Sidebar

Related Questions

Let's say I want to have a function which reads data from the SerialPort
I have a MySQL database and with a php function i made a table
I have a remote form with hand-made buttons using tags. I'm using data-remote=true in
I have made this function, that seems to work fine, but it return #
So I'm using this function I made to read images from the users hard
I have made one function in which I am passing a matrix and returning
Hi have made this function which is made to replicate an error that I
I have made a function to cound the weeks in a year, and that
i have made a function to add new upload and description inputs onClick. How
PHP: I have made up a function that returns an array. I would like

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.