Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 1.94 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. $dbhost = "sql.njit.edu";
  3. $dbuser = "kdm9_proj";
  4. $dbpass = "vhI5Wj7P";
  5. $dbh = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to MySQL");
  6. $dbname = "kdm9_proj";
  7. $selected  = mysql_select_db($dbname,$dbh);
  8. $courseandtime = mysql_query ("SELECT SESSION.SID, Location, Time, MaxEnrollment, COUNT(REGISTERED.SID) FROM SESSION, REGISTERED WHERE REGISTERED.CID=('$_POST[CID]') AND  SESSION.Time=('$_POST[Time]') AND SESSION.SID = REGISTERED.SID");
  9.  
  10.  
  11.  
  12.  
  13. echo "Sessions available for ";
  14. echo $_POST[CID];
  15. echo " at ";
  16. echo $_POST[Time];
  17. echo ":";
  18. echo "<BR><BR>";
  19.  
  20. echo "<table border='1'>
  21. <tr>
  22. <th>Session</th>
  23. <th>Location</th>
  24. <th>Time</th>
  25. <th>Max Enrollment</th>
  26. <th>Currently Enrolled</th>
  27. </tr>";
  28.  
  29. while($row = mysql_fetch_array($courseandtime))
  30.   {
  31.   echo "<tr>";
  32.   echo "<td>" . $row['SID'] . "</td>";
  33.   echo "<td>" . $row['Location']. "</td>";
  34.   echo "<td>" . $row['Time'] . "</td>";
  35.   echo "<td>" . $row['MaxEnrollment'] . "</td>";
  36.   echo "<td>" . $row['COUNT(REGISTERED.SID)'] . "</td>";
  37.   echo "</tr>";
  38.   }
  39.  
  40.  
  41.  
  42. echo "</table>";
  43.  
  44. if($courseandtime) {  $max_e = $courseandtime['MaxEnrollment']; $current_e = $courseandtime['COUNT(REGISTERED.SID)']; }
  45.  
  46.         if ($current_e < $max_e) {
  47.             echo "
  48.            <form action='register-exec.php' method='post'>
  49.            <label>Time: $_POST[Time]</label><br>
  50.            <input type='hidden' value='$Time' /><br><br>
  51.            <label>Student ID:</label><br>
  52.            <input type='text' name='SUCID' id='SUCID' /><br><br>
  53.            <label>CID: $_POST[CID]</label><br>
  54.            <input type='hidden' name='CID' id='CID' /><br><br>
  55.                    <label>SID: $row['SID']</label><br>
  56.                    <input type='hidden' name='SID' id='SID' value='$courseandtime[\"SID\"]' />
  57.            <button type='submit'>Register</button>
  58.            </form>
  59.            ";
  60.         }
  61.         else {
  62.             echo 'Sorry, were full!';
  63.         }
  64.  
  65.  
  66. mysql_close($dbh);
  67. ?>