RE: [PHP-DB] Select Query--Need help urgently
Irin said: > $sql = mysql_query("SELECT * FROM class where timetable_day='Monday'"); Oops, I see that he DID do a mysql_query and save the result resource in $sql. Sorry, guys! I haven't had my coffee yet this morning! Katie Dewees Web Developer E-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Query--Need help urgently
Irin said: > $sql = mysql_query("SELECT * FROM class where timetable_day='Monday'"); > > $row = mysql_fetch_array($sql); > $result = $db->query($sql); > $numofrows = mysql_num_rows($sql); >From the PHP manual: array mysql_fetch_array ( resource result [, int result_type]) You can't send the function mysql_fetch_array a string as a parameter. It needs a result resource. Assuming that your $db class returns a result resource, you can try this: $sql = "SELECT * FROM table"; $result = $db->query($sql); $row = mysql_fetch_array($result); $numofrows = mysql_num_rows($result); If for some reason you don't know what that class function "query" is returning, you can do it this way and it will work for sure: $sql = "SELECT * FROM table"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $numofrows = mysql_num_rows($result); HTH, Katie Dewees Web Developer E-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Query--Need help urgently
Hi! Hello irinchiang, Saturday, March 27, 2004, 8:52:51 AM, you wrote: ijc> Hi all, ijc> But I was unable to retrieve the values from database. Was it because I have ijc> written the SELECT query wrongly?? ijc> Realli need some help urgently..Hope to hear from all soon. Thanks in advance. ijc> Regards, ijc> Irin Can you exactly describe results of your query? And I noticed that tablename - "Class", but in query it's "class"... Try to correct and write the results. -- Best wishes, Mikhail U. Petrov PHP-programmer -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Select Query--Need help urgently
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: $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 ""; echo ""; echo "\n"; echo ""; echo "Monday"; echo "Time"; echo "Classcode"; echo "Level"; echo "Tutor"; echo ""; echo "".$row ['timetable_time'].""; echo "".$row ['class_code'].""; echo "".$row ['edu_level'].""; echo "".$row ['tutor_name'].""; echo ""; 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