PHP: Checkbox to delete database values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #16
    Originally posted by TheServant
    I think what he means is can you have:
    [code=php]
    echo <<<SOMETHING
    First
    Second
    Last
    SOMETHING;
    [/code]
    Ahh, I see. That didn't even occur to me :P
    Nice to know tho.

    Comment

    • kierandes
      New Member
      • Apr 2008
      • 25

      #17
      Originally posted by ronverdonk
      kierandes: Please enclose your posted code in [code] tags (See How to Ask a Question).

      This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

      Please use [code] tags in future.

      MODERATOR
      Noted. Will do in future. Apolagies for any inconvenience

      Comment

      • kierandes
        New Member
        • Apr 2008
        • 25

        #18
        I have gained more ground on the deleting part.

        I worked on gettinig the row id and sending that to a delete.php page,
        on the delete.php page I have a script For deleting the row. The id value is getting from the first page to the second page. but the rows are not deleting.

        Code:
         echo "<a href='delete.php?cmd=delete&id=$id'>$title - Delete</a>";
        thats my script on the first page that sends the id to the second page.


        <
        Code:
        if($_GET["cmd"]=="delete")
        {
            $sql = "DELETE FROM 'quay_messageboard' WHERE id=$id";
            $result = mysql_query($sql);
            echo "Row deleted!";
        
        }
        ?>
        the code above is the code from the second page where the magic should happen but alas its not working. Any tips or ideas guys?
        Thanks

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #19
          The reason why this particular statement does not work is that you may not enclose db names, such as table and column names, with quotation marks. Only 'back-ticks' are allowed. So this statement should be[code=sql]$sql = "DELETE FROM `quay_messagebo ard` WHERE id=$id";[/code]You would have found this error when you always test the result of a query or command (either MySQL or PHP), like here:[php]$result = mysql_query($sq l)
          or die("DELETE error: ".mysql_error() );[/php]Ronald

          Comment

          • kierandes
            New Member
            • Apr 2008
            • 25

            #20
            Originally posted by ronverdonk
            The reason why this particular statement does not work is that you may not enclose db names, such as table and column names, with quotation marks. Only 'back-ticks' are allowed. So this statement should be[code=sql]$sql = "DELETE FROM `quay_messagebo ard` WHERE id=$id";[/code]You would have found this error when you always test the result of a query or command (either MySQL or PHP), like here:[php]$result = mysql_query($sq l)
            or die("DELETE error: ".mysql_error() );[/php]Ronald
            That did the trick, thanks Ronald

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #21
              Originally posted by kierandes
              That did the trick, thanks Ronald
              You are welcome. See you next time.

              Ronald

              Comment

              Working...