PHP
  Home arrow PHP arrow Page 3 - Completing the Project Management Application
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? 
Google.com  
PHP

Completing the Project Management Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2008-07-14


    Table of Contents:
  • Completing the Project Management Application
  • Code Explained
  • The view_staff script
  • HTML Form

  • 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


    Completing the Project Management Application - The view_staff script
    ( Page 3 of 4 )

    The view staff page lists all the staff members that are involved in a project. It runs a query to retrieve all the names from the staff table that match a particular project id, and then builds a dynamic table based on the result of the table. Below is a screen shot of what the page looks like:


    And below is the code that makes up the page:

    <?php

    include "dbcon.php";

    include "functions.php";


    if(isset($_GET['pid'])){

    //clean pid

    if(!is_numeric($_GET['pid'])){

    //the value received is not numeric. redirect the user to login

    header("location:login.php");

    }


    //otherwise clean the received value for query use


    $cpid = mysql_escape_string($_GET['pid']);


    //get project name


    $getname = "SELECT title FROM projects WHERE pid = '".$cpid."'";

    $g_result = mysql_query($getname);

    if(!$g_result){

    echo mysql_error()

    }else{

    $rowname = mysql_fetch_assoc($g_result);

    $title = $row['title'];

    }

    //get the files

    $gettaff="SELECT * FROM staff WHERE p_id = '".$cpid."' ORDER BY sid";

    $result = mysql_query($gettaff);

    if(!$result){

    echo mysql_error();

    }else{

    $num=mysql_num_rows($result);

    }


    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/PM_Main.dwt.php" codeOutsideHTMLIsLocked="false" -->

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <!-- InstanceBeginEditable name="doctitle" -->

    <title>Untitled Document</title>

    <!-- InstanceEndEditable -->

    <!-- InstanceBeginEditable name="head" -->

    <!-- InstanceEndEditable -->

    <link href="Templates/main.css" rel="stylesheet" type="text/css" />

    </head>


    <body>

    <table width="100%" border="0">

    <tr>

    <td width="33%">&nbsp;</td>

    <td width="28%">&nbsp;</td>

    <td width="39%">Logged in: <!-- InstanceBeginEditable name="login" --><? echo $_SESSION['name'];?> | <a href="logout.php">Logout</a><!-- InstanceEndEditable --></td>

    </tr>

    <tr>

    <td colspan="3" bgcolor="#6699CC" class="headertxt">Project Management Software </td>

    </tr>

    <tr>

    <td colspan="3"><!-- InstanceBeginEditable name="main" --> <table width="99%" border="0">

    <tr>

    <td colspan="2" class="loginheader"><?php echo $title;?> </td>

    </tr>

    <tr>

    <td width="44%">Members of this project: </td>

    <td width="56%">&nbsp;</td>

    </tr>

    <tr>

    <td>&nbsp;</td>

    <td>&nbsp;</td>

    </tr>

    <tr>

    <td><strong> Name</strong></td>

    <td><strong>Action</strong></td>

    </tr>

    <?php

    if($num > 0){

    while($row = mysql_fetch_assoc($result)){?>

    <tr>

    <td><?php echo $row['name']?> </td>

    <td><a href="delete_member.php?sid=<?php echo $row['sid']?> & cpid=<?php echo $cpid?> ">Delete</a></td>

    </tr>

    <?php

    }

    }else{

    ?>

    <tr>

    <td colspan="2"><p>There are no members registered for this project.</p></td>

    </tr>

    <?php }

     

    ?>

    </table><!-- InstanceEndEditable --></td>

    </tr>

    <tr>

    <td colspan="3"><!-- InstanceBeginEditable name="nav" --><a href="main.php">View Project List</a> | <a href="admin/login.php">Administrators Corner </a><!-- InstanceEndEditable --></td>

    </tr>

    <tr>

    <td align="right" class="cright" colspan="3">copyright &copy; 2007 PM </td>

    </tr>

    </table>

    </body>

    <!-- InstanceEnd --></html>


    delete

    <?php

    include "dbcon.php";

    include "functions.php";

    $remove = "DELETE FROM staff WHERE sid = '".$_GET['sid']."'";

    mysql_query($remove);

    header("localtion:view_staff.php?pid=".$_GET['cpid']."");


    ?>



    The code starts by checking to see if the pid is numeric or not. If it is not numeric, we will not be able to run the script at all. If it is numeric, it is escaped and ready to be used in a MySQL query:


    <?php

    include "dbcon.php";

    include "functions.php";


    if(isset($_GET['pid'])){

    //clean pid

    if(!is_numeric($_GET['pid'])){

    //the value received is not numeric. redirect the user to login

    header("location:login.php");

    }


    //otherwise clean the received value for query use


    $cpid = mysql_escape_string($_GET['pid']);


    PHP then runs a query to retrieve the name of the project concerned, and stores the name in a variable called $title:


    //get project name

    $getname = "SELECT title FROM projects WHERE pid = '".$cpid."'";

    $g_result = mysql_query($getname);

    if(!$g_result){

    echo mysql_error()

    }else{

    $rowname = mysql_fetch_assoc($g_result);

    $title = $row['title'];

    }


    Finally the query to get the list of staff names that work on the project is queried. The results are then stored in the $num variable:

    //get the files

    $getstaff="SELECT * FROM staff WHERE p_id = '".$cpid."' ORDER BY sid";

    $result = mysql_query($gettaff);

    if(!$result){

    echo mysql_error();

    }else{

    $num=mysql_num_rows($result);

    }


    ?>



     
     
    >>> More PHP Articles          >>> More By David Web
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - 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





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek