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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:29:33+00:00 2026-06-02T05:29:33+00:00

I’m pretty new to PHP, so please forgive me if this question is obnoxiously

  • 0

I’m pretty new to PHP, so please forgive me if this question is obnoxiously noob…

I have a page that lists close to 150 records from a database. I want the user to only be able to delete one record at a time (no checkboxes). I want there to be a delete button next to each name, and when the user clicks it, the page refreshes with the updated list and success message above saying: “%Name% was deleted successfully”. (where %Name% is the actual name they deleted)

My question is: Can I do this with a form? If so, what form element would I assign the Name and delete button to?

Or, do I need to set the delete button as an anchor element, with the URL set to a page that can process the delete request, then redirects the user back (my concern there is the only way I can send the “Success” message back, that I know of is through a Session variable, is that ok?)

Or, is there some other way completely that I don’t know of?

Any feedback would be greatly appreciated.
Thanks

  • 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-02T05:29:35+00:00Added an answer on June 2, 2026 at 5:29 am

    you can do it both way… here the key concept is having a unique field like id in the database for eg you have id,name,username and password field in database table so look at both the ways below

    1. using hyperlink

    <?php
    mysql_connect("fostname","username","password");
    mysql_select_db("database_name");
    $q = mysql_query("SELECT * FROM tbl_name");
    if(mysql_num_rows($q)>0)
    {
    echo"<table>";
    echo "<tr><td>name</td><td>action</td></tr>";
    while($name = mysql_fetch_assoc($q))
    {
    ?>
    
    <tr><td><?php echo $name['name'];?></td><td><a href="delete.php?id=<?php echo $name['id'];?>">Delete</a></td></tr>
    <?php
    }
    
    echo "</table>";
    }
    ?>
    

    this is what you do in listing page…. now look at delete.php which needs to be on the path as defined in hyperlink

    delete.php

    <?php
    mysql_connect("fostname","username","password");
    mysql_select_db("database_name");
    $id = $_GET['id'];
    $q = mysql_query("delete from tbl_name where id = '$id'");
    header("Location: list.php");
    ?>
    

    2. Using form

    <?php
        mysql_connect("fostname","username","password");
        mysql_select_db("database_name");
        $q = mysql_query("SELECT * FROM tbl_name");
        if(mysql_num_rows($q)>0)
        {
        echo"<table>";
        echo "<tr><td>name</td><td>action</td></tr>";
        while($name = mysql_fetch_assoc($q))
        {
        ?>
    
        <tr><td><?php echo $name['name'];?></td><td><form action='delete.php' method='post'> <input type='hidden' value='<?php echo $name["id"];?>'></form></td></tr>
        <?php
        }
    
        echo "</table>";
        }
        ?>
    

    delete.php

    <?php
        mysql_connect("fostname","username","password");
        mysql_select_db("database_name");
        $id = $_POSTs['id'];
        $q = mysql_query("delete from tbl_name where id = '$id'");
        header("Location: list.php");
        ?>
    

    (note: list.php is the page where you list all the info)

    • 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
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.