Expand|Select|Wrap|Line Numbers
- <?php
- $dbhost = 'unix.lsbu.ac.uk';
- $dbuser = 'lrc3';
- $dbpass = 'dietdft_';
- $dbname = 'lrc3';
- // This is an example open a db
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
- mysql_select_db($dbname);
- $today = date("d/m/Y");
- $day=substr($today, 0, 2);
- $month = substr($today, 3, 2);
- $year = substr($today, 6, 4);
- $search_date = mktime(0,0,0, $month, $day, $year);
- // counting the offset
- $offset = ($pageNum - 1) * $rowsPerPage;
- $query = "SELECT * FROM class where module = '$module' and timestamp > '$search_date'";
- $result = mysql_query($query) or die('Error, query failed');
- $num=mysql_numrows($result);
- echo "<P class=style19>$num test dates match your criteria of $module";
- //echo "<p class=style19>Possible matches reference $module are ".$num."</P>";//
- while($row=mysql_fetch_array($result))
- {
- if ($row['time']=="0")
- {
- $output="";
- }
- if ($row['time']=="1")
- {
- $output=" at 1.00pm";
- }
- if ($row['time']=="2")
- {
- $output=" at 2.00pm";
- }
- if ($row['time']=="3")
- {
- $output=" at 3.00pm";
- }
- if ($row['time']=="4")
- {
- $output=" at 4.00pm";
- }
- if ($row['time']=="5")
- {
- $output=" at 5.00pm";
- }
- //convert timestamp to date format for display//
- $displaytime=$row[timestamp];
- $thedate= date("d-m-y", $displaytime);
- // get class primary and assign it to varible //
- $id = $row[id];
- $look_id = $id;
- // calculate avaliability check //
- $avalible = "select * from enrol where class_id='$id'";
- $result1 = mysql_query($avalible);
- $num_rows = mysql_num_rows($result1);
- //$query_enrol = "select * from class where module = '$module';//
- // display response to query on screen //
- echo "<p class=style21>";
- echo ("<br>Exam scheduled on: ".$thedate);
- echo $output;
- $unit = $row[units];
- $avaliblility = $unit - $num_rows;
- echo ("<BR>Class size: ".$row[units].", spaces avaliable: ".$avaliblility);
- echo ("<br><a href=\"javascript:document.form1.submit($row[id])\">Click here to book this test </a><P></p> ");
- echo ("<input name=\"id\" type=\"hidden\" value=$id >");
- echo ("<P>id: ".$id);
- echo ("<P>lid: ".$look_id);
- }
- mysql_close($conn);
- ?>
3 test dates match your criteria of Module 2 - Using the Computer and Managing Files (XP/2003)
Exam scheduled on: 10-07-07 at 1.00pm
Class size: 22, spaces avaliable: 21
Click here to book this test
id: 37
lid: 37
Exam scheduled on: 11-07-07 at 2.00pm
Class size: 20, spaces avaliable: 20
Click here to book this test
links are passing wrong value
id: 38
lid: 38
Exam scheduled on: 09-07-07 at 4.00pm
Class size: 25, spaces avaliable: 23
Click here to book this test
id: 39
lid: 39
passing wrong varible. Pls help,