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

  • Home
  • SEARCH
  • 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 7849433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:31:01+00:00 2026-06-02T18:31:01+00:00

I’m attempting to make a function that will allow users to delete posts they

  • 0

I’m attempting to make a function that will allow users to delete posts they have left. Basically I’m trying to select an ID and then pass it off to another function to delete it. The current code is deleting every comment, not just the comment linked to the ID like I’m attempting to.

Here are the table values

Table eventUpdates
ID - unique ID. Trying to use this value to delete the post
eventID - references an eventID from another table
eventReply - the "message" or response
eventUserID -ID of the user posting the message
username -username of the person
eventTimestamp -timestamp

So, currently every response is being deleted. I can’t get it to delete just the ID that I send.

<table border ="1">
<?
$eventUpdates = mysql_query($sql);
while ($list = mysql_fetch_assoc($eventUpdates)) {  
        echo $updateID;
                echo '<tr><td>';
                    echo $list['username'],"</br>", $list['eventTimestamp'],'<br/>';
                        if($list['eventUserID'] == $userid){ //used for deleting posts. Checks the session to make sure it's the user who made the post
                                ?>
                                <form method="post">
                                <input type="submit" name="deleteUpdate" value="Delete Update">
                                </form>
                                <?
                                if(isset($_POST['deleteUpdate'])){
                                    $updateID = $list['ID'];
                                    $delete = new postprocessing;
                                    $delete->deleteEventUpdate($updateID);
                                    echo '<meta http-equiv="refresh" content="0;url=main.php">';
                                }
                        }
                        echo '</td><td>';
                        echo $list['eventReply'];
                        echo '</td></tr>';
}

Here is the function used to delete it

function deleteEventUpdate($ID){
   mysql_query("delete from eventUpdates where ID = '$ID'");
}
  • 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-02T18:31:04+00:00Added an answer on June 2, 2026 at 6:31 pm

    This is because you haven’t specified the ID you want to delete in the post array, so every comment they created “matches” the deletion criteria. The $_POST array looks like:

    $_POST = array(‘deleteUpdate’=’Delete Update’);

    so when you’re looping through the list of events, every comment that the user ‘owns’ ($list['eventUserID'] == $userid) matches the criteria “isset($_POST['deleteUpdate'])“:

    You need to include a hidden input with the ID the specific comment you want to delete and match against it as well:

    <form method="post">
    <input type="submit" name="deleteUpdate" value="Delete Update">
    <input name='post_id' value="<?php echo $list['ID'];?>" type='hidden' />
    </form>
    

    and then in the loop:

    if(isset($_POST['deleteUpdate']) && isset($_POST['post_id']) && $_POST['post_id']==$list['ID']){...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.