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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:01:01+00:00 2026-06-09T02:01:01+00:00

I need some help with PHP and SQL. Im doing a website where you

  • 0

I need some help with PHP and SQL. Im doing a website where you can post notes in different subjects (Work, Home, School, and so on). After every note that being selected from my database I want a button that can delete that specific post when it’s not needed anymore. I can make it delete but is deletes wrong note, always the one above or below. I don’t know whats wrong with my code? Please help me.

    <?php 
    $query = "SELECT * FROM notes WHERE subject='Work' order by id desc";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) { 
            $id = $row['id'];
            $subject = $row['subject'];
            $date = $row['date'];
            $note = $row['note']; 

            print "<p><strong>$subject</strong> ($id), $date </p>"; 
            print "<p> $note </p>";

        ?>
        //delete button starts here here
        <form id="delete" method="post" action="">
        <input type="submit" name="delete" value="Delete!"/>    
        <?php
        if(isset($_POST['delete'])){
           $query = "DELETE FROM notes WHERE id=$id"; 
           $result = mysql_query($query);
        }
        ?>  
        </form>
        <?php
    }   
    ?>

And when I press delete I get this:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mirho663/www-pub/webbpage/menu2.php on line 40

What does that mean and how do I fix it?

  • 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-09T02:01:03+00:00Added an answer on June 9, 2026 at 2:01 am

    I updated your script below, try it if it works.

    <?php 
    
        if(isset($_POST['delete'])){
           $id = $_POST['delete_rec_id'];  
           $query = "DELETE FROM notes WHERE id=$id"; 
           $result = mysql_query($query);
        }
    
        $query = "SELECT * FROM notes WHERE subject='Work' order by id desc";
        $result = mysql_query($query);
        while ($row = mysql_fetch_array($result)) { 
                $id = $row['id'];
                $subject = $row['subject'];
                $date = $row['date'];
                $note = $row['note']; 
    
                print "<p><strong>$subject</strong> ($id), $date </p>"; 
                print "<p> $note </p>";
    
            ?>
            //delete button starts here here
            <form id="delete" method="post" action="">
            <input type="hidden" name="delete_rec_id" value="<?php print $id; ?>"/> 
            <input type="submit" name="delete" value="Delete!"/>    
    
            </form>
            <?php
        }   
        ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a bit new to sql and php so I need some help
I need some help structuring my php. I am trying to get 3 different
I´m working on a paymentsolution and need some help with the PHP. I´m doing
I need some help with PHP Class. I have limited knowledge about how it
I need some help with some PHP and MySQL code. At the moment I
I need some help with a small php problem. But i dont know how
I'm a noob with mysql and php, and need some help :) I have
I need some help sorting my score value's of my sql database <table border
I need some help with echoing an SQL field but it keeps showing Resource
I need some help with re-working the logic on this php code. What I'd

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.