bernie.nmsu Posted August 25, 2004 Share Posted August 25, 2004 I have a page where a user can make a selection from a list box of an instructor. Once the selection is made, the instructor key is passed into the URL variable. The next page that displays is supposed to only display courses that the instructor has listed in the database. If I take the variable out of the WHERE statement, I can place a literal in it's place and get the correct data. When I place the variable in the WHERE my page to display the courses fails. If I take out the where entirely, then I am able to display all courses stored in the table. The next step to this is to allow the user to select the course and then display a roster. I am using a GET on all my forms and creating a hidden field called instructorKey with the value of $HTTP_GET_VARS['instructorKey']. In my record set the variable is called colname with a runtime value of $HTTP_GET_VARS['instructorKey']. I know there has to be something simple that I'm leaving off to pass the data down based on the variable. Here is my SQL statement: SELECT TRAINING_COURSE.coursename, TRAINING_SCHEDULE.schedulestartdate FROM TRAINING_INSTRUCTOR INNER JOIN (TRAINING_COURSE INNER JOIN (TRAINING_ATTENDEE INNER JOIN TRAINING_SCHEDULE ON TRAINING_ATTENDEE.ScheduleKey = TRAINING_SCHEDULE.ScheduleKey) ON TRAINING_COURSE.CourseKey = TRAINING_SCHEDULE.CourseKey) ON TRAINING_INSTRUCTOR.InstructorKey = TRAINING_SCHEDULE.InstructorKey WHERE TRAINING_INSTRUCTOR.InstructorKey = colname Quote Link to comment https://forums.phpfreaks.com/topic/1936-problem-using-a-url-variable-in-a-sql-statement/ Share on other sites More sharing options...
morpheus.100 Posted August 28, 2004 Share Posted August 28, 2004 Just use $_GET['vars'] No need for superglobal. Quote Link to comment https://forums.phpfreaks.com/topic/1936-problem-using-a-url-variable-in-a-sql-statement/#findComment-6310 Share on other sites More sharing options...
bernie.nmsu Posted August 31, 2004 Author Share Posted August 31, 2004 Thanks for the help this resolved the problem. Quote Link to comment https://forums.phpfreaks.com/topic/1936-problem-using-a-url-variable-in-a-sql-statement/#findComment-6325 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.