this below is my code for the student menu
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Module Selector</title>
- <style>
- tr {background-color:lightblue;}
- td {text-align:center;}
- </style>
- </head>
- <body>
- <h1> Rate The Modules in Order of Prefrence With 1 Being The Highest</h1>
- <form action= "<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
- <?php
- require_once "./includes/connection.inc.php";
- $conn = dbConnect();
- //echo 'connected';
- //Ruth Gammack - prepare statement to count the number of modules available for student
- $sel = $conn->prepare('select count(*) from module student where student.courseID = courseID');
- $sql = "SELECT * FROM module student WHERE student.courseID = courseID";
- $stmt = $conn->prepare($sql);
- try {
- $stmt->execute();
- $sel->execute();
- $results = $stmt->fetchAll();
- $count = $sel->fetchColumn();
- if (!$results){ // check we have some results
- echo "No modules Available at this time please try again later <br />";
- }
- else{ //generate table of modules
- print "<table>\n";
- echo "<th>ModuleID</th><th>Name</th><th>Description</th><th>Lecturer</th><th>Ranking</th>";
- {
- foreach ($results as $row){
- echo "<tr>";
- echo "<td>".$row["moduleID"]."</td>";
- echo "<td>".$row["ModuleName"]."</td>";
- echo "<td>".$row["ModuleDesc"]."</td>";
- echo "<td>".$row["LecturerID"]."</td>";
- //Display a dropdown for each module selected for the user from the database
- echo "<td><select name='modRankDropdown'>";
- //Ruth Gammack- using a temp count = to the count returned from the database
- $tempcount = $count;
- //while the count is more than 0 echo the temp count in the option box and the decrement by one
- while ($tempcount > 0){
- echo "<option value='".$tempcount."'>".$tempcount."</option>";
- $tempcount--;
- }
- echo"</select></td>";
- }
- }
- echo "</table>";
- echo "<br> Confirm Modules: <INPUT TYPE = 'Submit' Name = 'Submit' VALUE = 'Submit'>";
- }
- } catch ( PDOException $e ) {
- echo "Query failed: " . $e->getMessage();
- }
- // close database connection
- dbClose($conn);
- ?>
- </form>
- <a href="choices.php?action=viewChoices">View Choices</a>
- </body>
- </html>