MySQL
  Home arrow MySQL arrow Page 2 - The Perfect Job (part 2)
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 
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? 
MYSQL

The Perfect Job (part 2)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2001-07-11

    Table of Contents:
  • The Perfect Job (part 2)
  • Administrator Ahoy!
  • Adding To The Mix
  • Changing Things Around
  • Building Blocks
  • Handling The Gray Areas
  • Endgame

  • 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


    The Perfect Job (part 2) - Administrator Ahoy!


    (Page 2 of 7 )

    If you remember, when I first put together the "listings" table, I added a couple of dummy entries to it, just to get things rolling.

    Now, that's fine during the early stages of application development...but you can't expect your customers to pop open a mySQL prompt every time they need to update a job listing. For one thing, they may not have the technical acumen necessary to manipulate a mySQL database; for another, they may prefer a pretty GUI to an ugly command-line. Either way, as the developer, you're on the hook to package those functions into your application as well.

    Consequently, I'll begin by putting together an entry point for administrators, in much the same way as I did for users. This page will serve as a menu to the different administration functions available.

    <? // admin.php - admin functions entry point // includes // open connection to database $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); // get list of departments with open jobs $query = "SELECT DISTINCT id, department from department, listing WHERE department.id = listing.fk_department"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // generate a table echo "<table border=0 cellspacing=5 cellpadding=5>"; // iterate through resultset while(list($id, $department) = mysql_fetch_row($result)) { // print department name echo "<tr><td colspan=4><b>Department:</b> $department</td></tr>"; // look for jobs within the department and print as list, add edit and delete links $query2 = "SELECT jcode, designation from listing WHERE listing.fk_department = '$id'"; $result2 = mysql_db_query($database, $query2, $connection) or die ("Error in query: $query2. " . mysql_error()); while(list($jcode, $dsg) = mysql_fetch_row($result2)) { echo "<tr><td width=10> </td><td>$dsg ($jcode)</td> <td><a href=edit.php?jcode=$jcode><font size=-1>edit</font></a></td> <td><a href=delete.php?jcode=$jcode><font size=-1>delete</font></a></td></tr>"; } } echo "</table>"; ?> <!-- snip --> <a href="add.php">Add a new listing</a> or <a href="search.php">search the database</a> <!-- snip -->
    Here's what it looks like.



    As you can see, it's almost identical to the user entry point, with the exception of the edit and delete links next to each job. Each of these calls a script to perform the appropriate function. The bottom of the page also includes links to add a new listing, or search the database for potential candidates.

    It should be noted at this point that access to all these administration scripts should be restricted to privileged users only. The easiest way to do this is to move them into a separate directory, and protect it using Web-based authentication.

    This article copyright Melonfire 2001. All rights reserved.

    More MySQL Articles
    More By icarus, (c) Melonfire


     

       

    MYSQL ARTICLES

    - MySQL Server Tuning Tips and Tricks
    - MySQL Query Optimizations and Schema Design
    - MySQL Benchmarking Tools and Utilities
    - MySQL Benchmarking Concepts and Strategies
    - Take Some Load off MySQL with MemCached
    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL





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