Select Query--Need help urgently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all, 

I am having having a slight problem with SELECT query statement.

I have a table "Class". The table are as follow:

+----------------+--------------+------+-----+---------+----------------+
| Field          | Type         | Null | Key | Default | Extra          |
+----------------+--------------+------+-----+---------+----------------+
| class_id       | int(11)      |      | PRI | NULL    | auto_increment |
| class_code     | varchar(255) |      |     |         |                |
| edu_level      | varchar(16)  |      |     |         |                |
| student_name   | varchar(255) |      |     |         |                |
| tutor_name     | varchar(255) |      |     |         |                |
| timetable_day  | varchar(255) |      |     |         |                |
| timetable_time | varchar(255) |      |     |         |                |
+----------------+--------------+------+-----+---------+----------------+

I am doing a SELECT query to retrieve some of the fields like timetable_time, 
tutor_name, class_code and edu_level from the table WHERE the timetable_day is 
equal to "Monday" . Meaning it will display fields only when the timetable_day 
value is "Monday"

Below is a snip of my code:

<snip>

$timetable_time = $_GET["timetable_time"];
$class_code = $_GET["class_code"];
$edu_level = $_GET["edu_level"];
$tutor_name = $_GET["tutor_name"];

$sql = mysql_query("SELECT * FROM class where timetable_day='Monday'");

$row = mysql_fetch_array($sql);
$result = $db->query($sql);
$numofrows = mysql_num_rows($sql);

echo "<div align=\"center\">";
echo "<div id=\"pagecontent5\">";
echo "<table border=\"0\" width=\"700\" >\n";
echo "<tr class=\"darker\">";
echo "<td align=\"center\" colspan=\"4\"><b>Monday</b></td></tr>";
echo "<tr><td align=\"center\" class=\"darkgreen\" width=\"200\">Time</td>";
echo "<td align=\"center\" class=\"lightgreen\" width=\"150\">Classcode</td>";
echo "<td align=\"center\" class=\"darkgreen\" width=\"150\">Level</td>";
echo "<td align=\"center\" class=\"lightgreen\" width=\"200\">Tutor</td></tr>";
echo "</div>";


echo "<tr><td align=\"center\" class=\"darker\" width=\"200\">".$row
['timetable_time']."</td>";
echo "<td align=\"center\" class=\"lighter\" width=\"150\">".$row
['class_code']."</td>";
echo "<td align=\"center\" class=\"darker\" width=\"150\">".$row
['edu_level']."</td>";
echo "<td align=\"center\" class=\"lighter\" width=\"200\">".$row
['tutor_name']."</td></tr>";
echo "</div>";

</snip>

But I was unable to retrieve the values from database. Was it because I have 
written the SELECT query wrongly??

Realli need some help urgently..Hope to hear from all soon. Thanks in advance.

Regards, 
Irin

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux