I want to check that if I have in my first drop down list the year is 2001 and in the second dropdown list i select 1900 as the year then I will echo a message to the user that he should select a year that the first is lower than the second (ex: 2001<2002) and if it has that error then it should store the data in my database until he change it.
My code to update the database is the below....
if(isset($_POST['id'])){
$id = $_POST['id'];
$school = mysql_real_escape_string($_POST["school"]);
$degree = mysql_real_escape_string($_POST["degree"]);
$website = mysql_real_escape_string($_POST["website"]);
$start_date = mysql_real_escape_string($_POST["start_date"]);
$end_date = mysql_real_escape_string($_POST["end_date"]);
$start_year = mysql_real_escape_string($_POST["start_year"]);
$end_year = mysql_real_escape_string($_POST["end_year"]);
$degree_description = mysql_real_escape_string($_POST["degree_description"]);
$query="UPDATE education
SET school = '$school', degree = '$degree', website = '$website', start_date='$start_date', end_date='$end_date', start_year='$start_year', end_year='$end_year', degree_description='$degree_description'
WHERE id='$id' AND username='$username'";
mysql_query($query)or die(mysql_error());
if(mysql_affected_rows()>=0){
echo "<p>($username) Record Updated<p>";
}else{
echo "<p>($username) Not Updated<p>";
}
}
else{
//first time, initialize as you wish. Probably need to get the first id for this user, using another query
$id = 0;
}
and i guess that my code in order to check the years is this ...
if($start_year>$end_year)
{
echo "The error Message";
}
But I cant find where i should place it in order to work correctly