Jump to content


Photo

problem using a url variable in a sql statement


  • Please log in to reply
2 replies to this topic

#1 bernie.nmsu

bernie.nmsu
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 25 August 2004 - 07:31 PM

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


#2 morpheus.100

morpheus.100
  • Members
  • PipPipPip
  • Advanced Member
  • 145 posts

Posted 28 August 2004 - 04:07 PM

Just use $_GET['vars']

No need for superglobal.

#3 bernie.nmsu

bernie.nmsu
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 31 August 2004 - 03:16 PM

Thanks for the help this resolved the problem.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users