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  
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

Time is Money (part 1)
By: The Disenchanted Developer, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 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:
      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


    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

    - 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 5 hosted by Hostway