wkilc Posted November 8, 2014 Share Posted November 8, 2014 If I query my database: www.mydomain.com/index.php?room=M210 I get both room M201 and M210B in my results. I know enough to know that is a result of: and (allstate_schedule.room LIKE '$room%') So I change it to this: and (allstate_schedule.room LIKE '$room') Now the query works correctly: www.mydomain.com/index.php?room=M210 But if I pull up an unfiltered list: www.mydomain.com/index.php ... I get my "No records found matching:" here is my code: $query = "SELECT allstate_schedule.sponsor,allstate_schedule.school,allstate_schedule.student,allstate_schedule.instrument,allstate_schedule.school,allstate_schedule.room,allstate_schedule.time from allstate_schedule WHERE ((allstate_schedule.sponsor LIKE '$sponsor%') and (allstate_schedule.student LIKE '%$student%') and (allstate_schedule.instrument LIKE '$instrument%') and (allstate_schedule.school LIKE '$school%') and (allstate_schedule.room LIKE '$room%') and (allstate_schedule.time LIKE '$time%')) ORDER BY allstate_schedule.$sort LIMIT $eu, $limit "; $resultt = mysql_query($query); // Determine the number of employees $number = mysql_num_rows($resultt); if ($number == 0) { print "<b>No records found matching</b>:"; $sponsor = $sponsor; $school = $school; $room = $room; $student = $student; Link to comment https://forums.phpfreaks.com/topic/292363-return-exact-room-number/ Share on other sites More sharing options...
Barand Posted November 8, 2014 Share Posted November 8, 2014 If no room is specified, don't include a room condition in the WHERE clause Link to comment https://forums.phpfreaks.com/topic/292363-return-exact-room-number/#findComment-1496107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.