~ankurd/coursefeedback/trunk

« back to all changes in this revision

Viewing changes to trunk/course.php

  • Committer: legaloslotr
  • Date: 2009-12-24 18:03:23 UTC
  • Revision ID: legaloslotr-20091224180323-qpggpum8j25vu6h0
Created course.php.
Improved 2 column css layout.
Bugfix in login system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
$pagetitle="Course";
 
3
require_once 'includes/header.php';
 
4
?>
 
5
<div id="main">
 
6
<h1>Courses @IITD</h1>
 
7
 
 
8
<?php
 
9
//connect to db
 
10
require_once 'conf/conf.php';
 
11
$dbc=mysqli_connect(dbConf::$dbHostname, dbConf::$dbUser, dbConf::$dbPasswd,dbConf::$dbName);
 
12
 
 
13
if (isset($_GET['courseId'])) { //if visitor wants particular course
 
14
    $q='SELECT * FROM courses WHERE courseId="'.$_GET['courseId'].'";';
 
15
    $r=mysqli_query($dbc,$q);
 
16
    if ($r ==false) {
 
17
        echo "<br> ".mysqli_error($dbc)."<br>"."Query: ".$q;
 
18
    }
 
19
    if (mysqli_num_rows($r)==0) { //courseId not found
 
20
        echo '<h2 class="largeHeading">Invalid Course Id</h2>';
 
21
        echo '<p>Click <a href="javascript:window.back();">here</a> to go back or <a href="course.php">here</a> to view all the courses available.</p>';
 
22
        exit();
 
23
    }
 
24
    $rows=mysqli_fetch_array($r);
 
25
    //get instructor info
 
26
    $q='SELECT * FROM professors WHERE profId = "'.$rows['instructorId'].'";';
 
27
    $r=mysqli_query($dbc,$q);
 
28
    if ($r ==false) {
 
29
        echo "<br> ".mysqli_error($dbc)."<br>"."Query: ".$q;
 
30
    }
 
31
    if (mysqli_num_rows($r)==0) {
 
32
        //instructor not found
 
33
    }
 
34
    $row2=mysqli_fetch_array($r);
 
35
    // print course info
 
36
    echo '<table class="courseData">';
 
37
    echo '<tbody>';
 
38
    echo '<tr>';
 
39
    echo "<th>Course</th>";
 
40
    echo "<td>{$rows['courseCode']}-{$rows['courseName']}</td>";
 
41
    echo '</tr>';
 
42
    echo "<tbody>";
 
43
    echo "<tr>";
 
44
    echo "<th>Description</th>";
 
45
    echo "<td><p>{$rows['courseDesc']}</p></td>";
 
46
    echo "</tr>";
 
47
    echo "<tr>";
 
48
    echo "<th>Instructor</th>";
 
49
    echo "<td>{$row2['name']}</td>";
 
50
    echo "</tr>";
 
51
    echo "</tbody>";
 
52
    echo "</table>";
 
53
    
 
54
}
 
55
else {    //display ability to choose course
 
56
}
 
57
 
 
58
 
 
59
    echo "</div>";
 
60
?>
 
61
 
 
62
<div id="sidebar">
 
63
<div id="login">
 
64
    <?php require_once('login/login_box.php'); ?>
 
65
</div>
 
66
</div>
 
67
 
 
68
<?php
 
69
require_once 'includes/footer.php';
 
70
?>