PHP
  Home arrow PHP arrow Page 8 - Time is Money (part 1)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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

Time is Money (part 1)
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    2001-10-22


    Table of Contents:
  • Time is Money (part 1)
  • Up A Creek
  • Bills, Bills, Bills
  • So Many Tables, So Little Time
  • Open Sesame
  • The Lazy Programmer Strikes Again
  • Today's Menu
  • Too Much Information
  • Time For Bed

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Time is Money (part 1) - Too Much Information
    ( Page 8 of 9 )

    With the main menu out of the way, let's now begin putting together the scripts corresponding to the different menu options. The first of these is the script "projects.php", which allows users to view a list of active projects.

    This is a very simple script - all it needs to do is connect to the database, retrieve a list of project names and associated descriptions, and print them in a neat list.

    <? // projects.php - display project list // includes include("config.php"); include("functions.php"); // check for valid user session session_start(); if(!session_is_registered("SESSION_UID")) { header("Location: error.php?ec=1"); exit; } ?> <html> <head> <basefont face="Verdana"> <style type="text/css"> TD {font-family: Verdana; font-size: smaller} </style> </head> <body bgcolor="white"> <? // display page header $title = "<a style=color:white href=menu.php>Main Menu</a> > View Project Descriptions"; include("header.inc.php"); ?> <!-- main table --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" align="left" width="60%"><b><font color="#3098C3">Project Descriptions</font></b></td> </tr> <tr> <td>&nbsp;</td> </tr> <? // open connection to database $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); // get project names and descriptions $query = "SELECT pname, pdesc FROM projects"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // iterate through resultset and display while (list($pname, $pdesc) = mysql_fetch_row($result)) { echo "<tr><td><ul><b><li>$pname</b><br>$pdesc</td>"; echo "<tr><td>&nbsp;</td>"; } // close connection mysql_close($connection); ?> </table> <? include("footer.inc.php"); ?> </body> </html>
    It looks simple, and it is. Here's what the output looks like:



    Almost identical in function is the script "tasks.php", which displays a list of standard tasks, together with definitions for each. The only difference lies in the query that is used - as you can see:

    <? // tasks.php - display task list // includes // check for valid user session // display page header // open connection to database $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); // get project names and descriptions $query = "SELECT tname, tdesc FROM tasks"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // iterate through resultset and display while (list($tname, $tdesc) = mysql_fetch_row($result)) { echo "<tr><td><ul><b><li>$tname</b><br>$tdesc</td>"; echo "<tr><td>&nbsp;</td>"; } // close connection mysql_close($connection); // include page footer ?>
    And here's what this baby looks like:



     
     
    >>> More PHP Articles          >>> More By The Disenchanted Developer, (c) Melonfire
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





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