SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query String - Delete Record

    Hiya Guys,

    I'm new to PHP and have finally come up with the following code that outputs all information contained in a table to the screen,
    whilst displaying a button beside each one.

    Upon a record being selected for deletion by clicking on the appropriate "Delete" button,
    How do I use a "Query String" to delete the particular record by ID?

    Code:
    <?php
    $con = mysql_connect("localhost","peter","abc123");
    if (!$con)
    {
      die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("WB", $con);
    
    $result = mysql_query("SELECT * FROM Birds");
    
    if(mysql_error() != 0 || mysql_num_rows($result) == 0)
    {
      die("No database, or no data");
    }
    
    while($row = mysql_fetch_object($result))
    {
      echo $row->Name . "<br>";
      echo $row->Species . "<br>";;
      echo $row->Sex . "<br>";;
      echo "<input type='submit' name='Submit' value='Delete'><br>";
    }
    ?>

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    So why did you have to start another thread about this?
    Saul

  3. #3
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query String - Delete Record

    Oops, this was supposed to be about Printing,

    My Mistake, Sorry.

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Edit it then? No one will notice, I'm sure.
    Saul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •