[ PHPXref.com ] [ Generated: Sun Jul 20 18:04:07 2008 ] [ gtd-php 0.6 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> listChecklist.php (source)

   1  <?php
   2      include_once ('header.php');
   3      include_once('config.php');
   4      $connection = mysql_connect($host, $user, $pass) or die ("unable to connect");
   5  
   6      mysql_select_db($db) or die ("unable to select database!");
   7          echo "<h2>Checklists</h2>";
   8  
   9  //SELECT categoryId, category, description FROM categories ORDER by category ASC
  10  
  11  //SJK  Allows viewing of checklists by category
  12                  echo '<form action="listChecklist.php" method="post">';
  13                  echo '<p>Category:';
  14                  $categoryId=(int) $_POST['categoryId'];
  15                  $query = "select * from categories";
  16                  $result = mysql_query($query) or die("Error in query");
  17                  echo '&nbsp;<select name="categoryId" title="Filter checklists by category">';
  18                  echo '<option value="0">All</option>';
  19                  while($row = mysql_fetch_row($result)){
  20                  if($row[0]==$categoryId){
  21                          echo "<option selected value='" .$row[0] . "'>" .stripslashes($row[1])."</option>\n";
  22                  } else {
  23                          echo "<option value='" .$row[0] . "'>" .stripslashes($row[1]). "</option>\n";
  24                          }
  25                  }
  26                  echo '</select>';
  27                  mysql_free_result($result);
  28                  echo '<input type="submit" align="right" class="button" value="Update" name="submit"></p>';  // $
  29  
  30          if ($categoryId==NULL) $categoryId='0';
  31          if ($categoryId=='0') {
  32                 $query = "SELECT checklist.checklistId, checklist.title, checklist.description,
  33          checklist.categoryId, categories.category 
  34          FROM checklist, categories 
  35          WHERE checklist.categoryId=categories.categoryId 
  36          ORDER BY categories.category ASC";
  37                  $result = mysql_query($query) or die ("Error in query");
  38                  }
  39          else {
  40                 $query = "SELECT checklist.checklistId, checklist.title, checklist.description,
  41          checklist.categoryId, categories.category 
  42          FROM checklist, categories 
  43          WHERE checklist.categoryId=categories.categoryId AND checklist.categoryId='$categoryId' 
  44          ORDER BY categories.category ASC";
  45                  $result = mysql_query($query) or die ("Error in query");
  46                  }
  47  
  48  
  49      if (mysql_num_rows($result) > 0){
  50          echo "Select checklist for report.";
  51          echo "<table>";
  52          echo '<tr>';
  53          echo '<th>Category</th>';
  54          echo '<th>Title</th>';
  55          echo '<th>Description</th>';
  56          echo '</tr>';
  57          while($row = mysql_fetch_row($result)){
  58              echo "<tr>";
  59              echo "<td>".stripslashes($row[4])."</td>";
  60              echo '<td><a href="checklistReport.php?checklistId='.$row[0].'&checklistTitle='.urlencode($row[1]).'">'.stripslashes($row[1]).'</a></td>';
  61              echo "<td>".stripslashes($row[2])."</td>";
  62              echo "</tr>";
  63          }
  64          echo "</table>";
  65      }
  66      else{
  67          echo "<h4>Nothing was found</h4>";
  68      }
  69  
  70      mysql_free_result($result);
  71      mysql_close($connection);
  72      include_once ('footer.php');
  73  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]