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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:42:08+00:00 2026-06-18T23:42:08+00:00

I am trying to delete a value in a comma seperated string in a

  • 0

I am trying to delete a value in a comma seperated string in a table. The script that does this (delete_url.php) works fine on it’s own if I set the post values manually, but I’m having a problem passing those values to the script with ajax. In the page that I want to pass the values from I have:

<script type="text/javascript">
            $(document).ready(function() {

                 $('.delete').click(function() {
        $.ajax({
            type: 'POST',
            url: '../scripts/delete_link.php', 
            data: 'link=' + $(this).attr('data_link') + '&topic_pk=' + $(this).attr('data_topic'),
            success: function() {

            }
        });        
    });
            });
        </script>

And:

<a class='delete_link' href='#' data_link='<?php echo urlencode($link); ?>' data_topic='<?php echo $topic_pk; ?>' onclick="return confirm('Are you certain you want to DELETE this link?')";><img src="../images/delete.png" width="16" height="16" alt="delete" title="delete this link" border='0' /></a>

I probably should be using json, but not sure of the correct way to do this. Thanks for any help.

  • 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-18T23:42:09+00:00Added an answer on June 18, 2026 at 11:42 pm

    I have updated my code with the folowing and now works deleting the record and removing the entry on the page:

    <script type="text/javascript">
    $(document).ready(function(){
    
        $('table#delTable td a.delete_link').click(function()
        {
            if (confirm("Are you sure you want to delete this row?"))
            {
                var id = $(this).parent().parent().attr('id');
                var data = 'id=' + id ;
                var parent = $(this).parent().parent();
    
                $.ajax(
                {
                       type: "POST",
                       url: '../scripts/delete_link.php',
                       data: 'link=' + $(this).attr('data_link') + '&topic_pk=' + $(this).attr('data_topic') + '&topic_introduction=' + $(this).attr('data_introduction'),
                       cache: false,
    
                       success: function()
                       {
                        parent.fadeOut('fast', function() {$(this).remove();});
                       }
                 });
            }
        });
    });
    
     </script>
    

    And the table:

    <table id='delTable' width="100%" border="0" cellpadding="5">
    <?php 
    if(!empty($retrieved_links)){
        foreach($retrieved_links as $link){
    ?>
      <tr>
        <td><?php echo $link; ?></td>
        <td width='16' align='center' valign='middle'><a class='delete_link' href='#' data_link='<?php echo urlencode($link); ?>' data_topic='<?php echo $topic_pk; ?>' data_introduction='<?php echo $topic_introduction; ?>'><img src="../images/delete.png" width="16" height="16" alt="delete" title="delete this link" border='0' /></a></td>
      </tr>
    <?php }
    }
    ?>
    </table>
    

    And delete_link.php:

    <?php
    require_once('../connection/connect.php');
    mysql_select_db($database, $connection);
    
    $link = urldecode($_POST['link']);
    $topic_pk = $_POST['topic_pk'];
    $topic_introduction = $_POST['topic_introduction'];
    
    
    if(!empty($link)){
    
    $query_get_topic = "SELECT * FROM topic WHERE topic_pk = '$topic_pk'";
    $result_get_topic = mysql_query($query_get_topic, $connection) or die(mysql_error());
    $row_get_topic = mysql_fetch_assoc($result_get_topic);
    
    $retrieved_links = explode(",", $row_get_topic['links']);   
    
    $delete_link = array_search($link,$retrieved_links);
    
    unset($retrieved_links[$delete_link]);
    $updated_links = mysql_real_escape_string(implode(',',$retrieved_links));
    
    $links_body = str_replace(',', '<p>', $updated_links);
    $topic = $topic_introduction . '<p>' . $links_body;
    
    $query = "UPDATE topic SET links = '$updated_links', topic = '$topic' WHERE topic_pk = '$topic_pk'";
    $result = mysql_query($query, $connection) or die(mysql_error());
    }
    mysql_close();
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to delete a the value cookie that I created after a
I'm trying to delete elements from a multidimensional-array based on a value. In this
I'm trying to delete the highest value from a group. Given this data: group_table
I'm trying to delete a row from a table in MySQL using the PHP
I am trying to delete a cookie with this function , but it doesnt
I am trying to delete MySQL table rows from a Web page using Perl.
I'm trying to delete all rows in a table using Castle ActiveRecord. Normally, I
I'm trying to delete all data from Table where index=Textbox1.Text and idnmb=Textbox2.Text When I
So at the moment I'm trying to delete files listed in the directory that
I have this JSON string in a PHP page: { elements: [{ type: pie,

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.