Here is what I'm trying to do. I need to check to see if a student has already been requested for that date and if so I need to check to see if the priority level is higher. If that returns no results I need to add the info to the table. I have these fields: student VARCHAR(150) class VARCHAR(150) date_requested INT(6) date_added INT(6) priority (2)
why not make a unique on student/date so there can be only one student with that unique date. But still not getting what you want, with a list of your table nothing is said here!
I need the SQL part of the code ... what I keep trying doesn't work. and no I want the old records to stay for a record.
As Eric suggested made sure that the exact value of requested already exists . Also please post more info we can barely understand what your script is doing . IDK where you get the input and what the script is suppose to do . Also please make a ID field with autoincrement , that's just good coding practice .
Kindly post your MySQL query, and if possible the accompanying PHP code here. Did you try anything just yet? Also, please explain this: who is 'requesting' for students? Or are the students requesting for lessons? This relationship is slightly unclear so it is hard to answer.
SELECT priority, date_requested FROM table_name WHERE student = "student-name" Code (markup): Once you get that out, you can do the processing for priority checking and date uniqueness checking within your PHP code. I usually prefer dumb databases and like to send as less processing overhead as possible to the DB.