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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:43:06+00:00 2026-06-16T07:43:06+00:00

I’m a beginner in web development. I made a simple table that shows the

  • 0

I’m a beginner in web development. I made a simple table that shows the id,answer and date of notes that I insert into the db.I need a simple script that shows a delete button for each note. I would like to know how can I get the id of each row I need to delete.
Here’s my php code:

<html>
<body>
<?php
 include '..//config.php';
 $result = mysql_query("SELECT * FROM **** Order by `id` ASC");
echo "<center><table width='400' border='1'>
<tr>
<th bgcolor='#D6D6D6' >ID</th>
<th bgcolor='#D6D6D6'>Answer</th>
<th bgcolor='#D6D6D6'>Date</th>
<th bgcolor='#D6D6D6'>Preview</th>
<th bgcolor='#D6D6D6'>Delete</th>
</tr>";


while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td bgcolor='#3399FF' scope='col width ='10%'>" . $row['id'] . "</td>";
  echo "<td width ='10%'>" . $row['answer'] . "</td>";
  echo "<td  bgcolor='#3399FF' scope='col width ='10%'>" . $row['date'] . " </td>";   
     if ($row['hidden'] > 'http://www.********/upload/upload/') {
  echo "<td width ='10%'><a href =" . $row['hidden'] . "><center>View</center></a></td>"; } else {echo "<td width ='10%'>" . $row[''] . "</td>";}
   echo "<td width ='10%'><a href = 'dlt.php'>Delete</a></td>";
   $row_id = $row['id'];
          }
  echo "</tr width ='10%'>"; 
  echo "</table></center>";
?>
</body>
</html>
  • 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-16T07:43:07+00:00Added an answer on June 16, 2026 at 7:43 am

    It’s not very clear from your question what your requirements are but I am assuming you want to know how you can pass the id of the entry when you click the “Delete” link (which is linked to dlt.php).

    You can pass a query string parameter to dlt.php with the id of the entry.

    I have cleaned up your code and modified it below:

    <!Doctype html>
    <html>
        <body>
        <?php
            include '../config.php';
            $result = mysql_query("SELECT * FROM **** Order by `id` ASC");
        ?>
            <center>
                <table width='400' border='1'>
                    <tr>
                        <th bgcolor='#D6D6D6'>ID</th>
                        <th bgcolor='#D6D6D6'>Answer</th>
                        <th bgcolor='#D6D6D6'>Date</th>
                        <th bgcolor='#D6D6D6'>Preview</th>
                        <th bgcolor='#D6D6D6'>Delete</th>
                    </tr>
    
                    <?php
                        while ($row = mysql_fetch_array($result)) {
    
                            $row_id = $row['id'];
                            ?>
                            <tr>
                                <td bgcolor='#3399FF' scope='col' width='10%'><?php echo $row_id; ?></td>
                                <td width='10%'><?php $row['answer']; ?></td>
                                <td  bgcolor='#3399FF' scope='col' width ='10%'><?php $row['date']; ?></td>
                                <td width ='10%'>
                                    <?php
                                        // I am not exactly sure what this line was meant to do in your code
                                        if ($row['hidden'] > 'http://www.********/upload/upload/') {
                                            echo "<a href='" . $row['hidden'] . "'><center>View</center></a>";
                                        }
                                    ?>
                                </td>
                                <td width ='10%'><a href='dlt.php?id=<?php echo $row_id; ?>'>Delete</a></td>
    
                            </tr>
    
                            <?php
                        }
    
                    ?>
                </table>
            </center>
        </body>
    </html>
    

    Then in your dlt.php file you can retrieve the id to be deleted using the following line:

    if (isset($_GET['id']) {
        $delete_id = $_GET['id'];
    }
    else {
        // no 'id' has been passed.
        die('Nothing to delete!');
    }
    $result = mysql_query("DELETE FROM **** WHERE `id` = $delete_id");
    

    Since you are new to web development (or development in general) you should be very careful about a couple of things:

    1. Write clean code with proper indentations. It helps you spot and debug your problems very quickly.
    2. Write W3C standards compliant code.
    3. Understand the technology API you want to use and beware of deprecated functions. For example in PHP mysql_* functions are deprecated. You should use mysqli or PDO instead.

    I’d put in more points but the list can actually get very long. These should be good for starters.

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

Sidebar

Related Questions

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
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I am using JSon response to parse title,date content and thumbnail images and place
this is what i have right now Drawing an RSS feed into the php,

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.