heshan Posted September 19, 2012 Share Posted September 19, 2012 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()); } ?> Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 19, 2012 Share Posted September 19, 2012 Not from that code, I'm afraid. You're missing some quite vital information in there, such as where you're outputting the data. Could also be a problem with the data itself, or the input process. So verify that the data in your database is correct first and foremost, then post the rest of the code. PS: You really need to read up on Input Validation and Output Escaping, your script is wide open for attackers to abuse. Also remember to remove mysql_error () when putting into production, replace it with a custom message which doesn't divulge any details about your script's inner workings. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 21, 2012 Share Posted September 21, 2012 Without the data, I'm guessing not all records have matching rows. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.