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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:41:18+00:00 2026-05-18T20:41:18+00:00

hoping you can help with what I expected to be a simple function. I’d

  • 0

hoping you can help with what I expected to be a simple function.

I’d like to allow users to remove (i.e. change published=y to published=n) a query result but can’t for the life of me figure out how to do it. Here’s the query as is:

$result = mysql_query("SELECT * FROM discussion WHERE publish='y' ORDER BY timestamp DESC");
while($row = mysql_fetch_array($result))
{
    echo ("<tr><td>" . $row['name'] . "<span class=\"remove\">(<a href=\"#\">REMOVE</a>)</span></td>
    <td width=\"300\">" . nl2br($row['question']) . "</td>
    <td>" . $row['author'] . "</td>
    <td>" . $row['timestamp'] . "</td>
    <td><a href=\"discussion.php?discussionID=" . $row['discussionID'] . "\">View Discussion</a></td></tr>");
}

The query I’d like to run when the user clicked ‘REMOVE’ (within the above query):

mysql_query("UPDATE discussion SET publish='n' WHERE discussionID='XXXXX");

Any ideas from the fine people at SO?

New to php/mysql so forgive the ignorance.

  • 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-05-18T20:41:19+00:00Added an answer on May 18, 2026 at 8:41 pm

    I think the simplest option here would be to insert your remove button into a form.

    Try adding this form into your table. I am echoing the discussionID into the checkbox so that you can distinguish between the multiple checkboxes in the table:

    <form method="post" action="">
         <input type="checkbox" id="removeCheckbox" name="removeCheckbox" value="<?php echo $row['discussionID']; ?>" />
         <input id="submit" name="submit" value="Submit" type="submit" />
    </form>
    

    And then in your PHP, you update the database with the value of the checkbox:

    <?php 
    
    if (isset($_POST['removeCheckbox'])) {
        $checkboxValue = $_POST['removeCheckbox'];
        mysql_query("UPDATE discussion SET publish='y' WHERE discussionID='$checkboxValue'");
    }
    
    ?>
    

    Does that make sense?

    EDIT: This should now work! Also updated to include Dan’s suggestion.

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

Sidebar

Related Questions

hoping you can help with what I expected to be a simple function. I'd
Hoping somebody can help me out - I would like to replace a certain
As a follow-up to this question I am hoping someone can help with the
I've never been much for math and I'm hoping that someone can help me
I'm hoping someone can help with this, as it's driving me absolutely nuts. I
I am hoping that there is someone that can help me and many others
I am hoping someone can help interpret the last code line (@Active=1....) for this
I'm hoping you can help me with a program I'm trying to write in
I'm still learning PHP Regex so I'm hoping someone can help me with what
Hoping someone can help me out with some pretty erratic behaviour from omnicomplete 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.