Ok, take a look at this code below and tell me what I'm doing wrong because I've tried just about everything I can think of to make it work and it just won't!
============================================
if ($action =="addscript" ) {
$start_date_from_form = strtotime("$start_year-$start_month-$start_number");
print("
<br>
");
$end_date_from_form = strtotime("$end_year-$end_month-$end_number");
$numresults=mysql_query("select id from courses_main where instructor = '$instructor' order by id");
$numrows=mysql_num_rows($numresults);
$result = mysql_query("select * from courses_main where instructor = '$instructor' order by id") or die("Cant connect to the database. Please try later");
for ($i=1; $i<=$numrows; $i++) {
if ($row = mysql_fetch_array($result)) {
$id = $row["id"];
$start_day = $row["start_day_db"];
$start_number = $row["start_number_db"];
$start_month = $row["start_month_db"];
$start_year = $row["start_year_db"];
$end_day = $row["end_day_db"];
$end_number = $row["end_number_db"];
$end_month = $row["end_month_db"];
$end_year = $row["end_year_db"];
$instructor = $row["instructor_db"];
$end_date = strtotime("$end_year_db-$end_month_db-$end_number_db");
$start_date = strtotime("$start_year_db-$start_month_db-$start_number_db");
$difference = $end_date - $start_date;
$result_one = $start_date_from_form - $start_date;
$result_two = $end_date - $start_date;
}}}
if ($result_one <= $result_two)
{
print("
<font face=\"Arial, Helvetica, sans-serif\" size=\"2\">INSTRUCTOR NOT AVAILABLE ON THAT DATE. PLEASE GO BACK AND SELECT ANOTHER DATE.<br></font>
");
}
elseif ($result_one > $result_two)
{
print("
<font face=\"Arial, Helvetica, sans-serif\" size=\"2\">THANK YOU. COURSE IS NOW BEING ADDED...</font>
");
//mysql_query ("insert into courses_main (course_title, location, instructor, start_day, start_number, start_month, start_year, duration, end_day, end_number, end_month, end_year, course_capacity, course_notes, added_by, course_type)
// values ('$course_title', '$location', '$instructor', '$start_day', '$start_number', '$start_month', '$start_year', '$duration', '$end_day', '$end_number', '$end_month', '$end_year', '$course_capacity', '$course_notes', '$name', '$course_type')");
//if ($multiple == "yes"){print("<meta http-equiv=\"refresh\" content=\"1;URL='?action=add&&name=$name'\"> adding new course details..."); }
//else {print("<meta http-equiv=\"refresh\" content=\"1;URL='?action=default&&name=$name'\"> adding new course details..."); }
What this code basically does is to avoid a member of staff being assigned to a course on a date which they already have a course. If they are already booked it rejects it, stops you adding the data and displays an error message. If the instructor is free on that date, it just adds the details to the database without problem.
What do you think? What am I doing wrong?