So what does the code in the previous section actually do? There are two rows of the table that need to be displayed based on the outcome of the $level variable check: <?php if($level =="admin"){?> If the value of the $level variable is admin, then the section of the code that you see above is built and displayed, based on the number of returned values from the query that we ran in the PHP portion of the page. The $num_admin variable is used in a while loop to extract the project name, status and creation date of the projects concerned. These details are then displayed in the resulting table rows that are created by this loop: <tr> <td><a href="view_project.php?pid=<?php echo $rowadmin['pid']?>"><?php echo $rowadmin['title'];?></a></td> <td><?php echo $rowadmin['status'];?></td> <td><?php echo $rowadmin['create_dt'];?> </td> </tr> Notice that there is also a dynamic hyperlink created with the title of the project. This link will enable the user to view the project concerned in detail when it is clicked. If the $num_admin variable value is zero -- in other words, no records could be found for this user -- then another dynamic table row is built to display this message: }else{ ?> <tr> <td colspan="3"><p>There does not seem to be any projects registered in your name. Click on the "Create New Project" link to create a project.</p></td> </tr> <?php }?> If the $level variable contains the "normal" value, then exactly the same sequence of events as described above occurs, except that the key variables that are used for the "while" loop and the variable used to extract the results of the query is different. Also, the records retrieved are specific to the logged-in user's ID. In other words, only the projects with a user ID that is the same as that of the logged-in user will be retrieved and displayed. That is all there is to the main page. The next page deals with looking at a particular project in detail. In fact, the hyperlink that is created by the dynamic table above opens this page when it is clicked, and lists all the details of a project. It lists how many staff are working on the project, their names, and the names of the files that are used in the project. Below is a screen shot of what the page looks like:
blog comments powered by Disqus |
|
|
|
|
|
|
|