PHP
  Home arrow PHP arrow Page 7 - Building A Quick-And-Dirty PHP/MySQL P...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building A Quick-And-Dirty PHP/MySQL Publishing System
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 42
    2002-03-12

    Table of Contents:
  • Building A Quick-And-Dirty PHP/MySQL Publishing System
  • A Little Slug-gish
  • A Maniac Is Born
  • Bedtime Stories
  • Admin Ahoy!
  • Splitting Up
  • Erasing The Past
  • Changing Things Around
  • Game Over

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building A Quick-And-Dirty PHP/MySQL Publishing System - Erasing The Past


    (Page 7 of 9 )

    So that takes care of adding new data to the database. Now, how about deleting it?

    You'll remember, from the discussion of "list.php" a few pages back, that the script "delete.php" is passed a $id variable, which holds the unique database identifier for the selected news item. The script "delete.php" needs this identifier in order to delete the correct record from the database.

    Here's the code that makes up "delete.php":

    <?
    // delete.php - delete a press release
    ?>

    <!-- page header - snip -->

    <?
    // includes
    include("../conf.php");
    include("../functions.php");

    // open database connection
    $connection = mysql_connect($host, $user, $pass) or die ("Unable to
    connect!");

    // select database
    mysql_select_db($db) or die ("Unable to select database!");

    // generate and execute query
    $query = "DELETE FROM news WHERE id = '$id'";
    $result = mysql_query($query) or die ("Error in query: $query. " .
    mysql_error());

    // close database connection
    mysql_close($connection);

    // print result
    echo "<font size=-1>Deletion successful. <a href=list.php>Go back to the
    main menu</a>.</font>";
    ?>

    <!-- page footer - snip -->
    This is so simple it hardly requires any explanation. The ID passed to the script via the $id variable is used to construct and execute a DELETE query, which removes the corresponding record from the database. Short, sweet and quite efficient.

    More PHP Articles
    More By icarus, (c) Melonfire


     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway