PHP
  Home arrow PHP arrow Page 3 - Creating an Administration Area for a ...
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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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

Creating an Administration Area for a Simple Threaded Discussion Forum
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2006-10-23

    Table of Contents:
  • Creating an Administration Area for a Simple Threaded Discussion Forum
  • Code
  • The delall() and deltopic($uid) functions
  • Database connection, bad words

  • 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


    Creating an Administration Area for a Simple Threaded Discussion Forum - The delall() and deltopic($uid) functions


    (Page 3 of 4 )

    The delall() function is pretty straightforward. It deletes all the records in the table.

    function delall(){
    forumdb();
    $query="Delete * from test";
    $result=mysql_query($query);
    if(!$result){
    echo 'Could not delete records because ' .mysql_error() . '';
    }else{
    echo 'All records have been delete';
    }
    }

    The deltopic($uid) function takes the uid of the record and uses that ID to delete it.

    function deltopic($uid){
    forumdb();
    if(is_numeric($uid)){
    $dbname="forum";
    $host="localhost";
    $dbh=mysql_connect($host) or die ('I cannot connect to the
    database because: ' . mysql_error());
    mysql_select_db ($dbname) or die('I cannot select the database
    because: ' . mysql_error());
    $query="Delete from test where uid=$uid Limit 1";
    $r=mysql_query($query);
    if(mysql_affected_rows()==1){
    echo "Record number <b>$uid</b> deleted";
    }else{
    echo "Could not delete record number <b>$uid</b> because
    " .mysql_error() . "";
    }
    }
    }

    In this function I've played it save and added the "Limit 1" statement to the delete query. This ensures that only one record is deleted and not all of them.

    More PHP Articles
    More By Jacques Noah


       · This is a very good article, clearly and profesionally written by this wonderful and...
       · Thanks for the encouraging comments!
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





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