Hi All,

I want to generate time table reports. A form includes labels to enter grade, class and stream. After selecting data user should click on "Generate" button and relevant time table details. The data is submitted for the following page and there was an empty set of data shown in the report. I want to know where i went wrong? The piece of PHP code is as follows.

table structure is as follows.

class (class_id, class_name, grade_id, stream)
subject (subject_id, name, --)
time_table (class_id, time_from, time_to, subject_id, date)

<?php 


public function myconnection(){
$this->con = mysql_connect("localhost","root","");

mysql_select_db("student_management", $this->con);

$grade=$_POST['grade_ID'];
$class=$_POST['class_ID'];
$stream=$_POST['stream_ID'];


$this->result = mysql_query("SELECT time_table.time_from, time_table.time_to, time_table.date, subject.name FROM time_table
                             INNER  JOIN subject ON time_table.subject_id=subject.subject_id INNER JOIN class 
                             ON  time_table.class_id=class.class_id WHERE class.class_name='$class' AND class.stream='$stream'") 
                             or die (mysql_error());

}
?>

If you are using PHPMyAdmin, create the query first from the Query button, then use it in php. It helps a lot.

Bukhari is right. Try that to see if it works, just substitute the variables. Perhaps there are just no results. Anyway, it would be difficult to advise on your query without your table structure and any sample data.

Your form variable is named class_ID, but the mysql column name is class_name. Looks fishy to me.