I want that I have an error message if that idno has finish to registered in 2015, No need to unique the idno cause I have to redundant because every year that idno can be save or register on the database but the problem is I want to check if he already registered in 2015 or 2016 or 2017.
Here is my code in saving student information:
<?php
if (isset($_POST['save'])){
$stud_id= $_POST['stud_id'];
$idno = $_POST['idno'];
$lastname = $_POST['lastname'];
$firstname = $_POST['firstname'];
$middlename= $_POST['middlename'];
$year= $_POST['year'];
$dept_id = $_POST['dept_id'];
$progid = $_POST['progid'];
$user_type = $_POST['user_type'];
$password= $_POST['password'];
$syear= $_POST['syearid'];
$YearNow=Date('Y');
$sql = mysql_query("SELECT * FROM student where idno = '$idno'")or die(mysql_error());
$count = mysql_num_rows($sql);
$sql1 = mysql_query("SELECT * FROM student,school_year where student.syearid = school_year.syearid AND school_year.from_year like $YearNow")or die(mysql_error());
$count1 = mysql_num_rows($sql1);
if (don't know what to condition on this part ) {
echo"idno $idno has already registered in that year";
}
else{
// query
$sql = "INSERT INTO student VALUES ('$stud_id','$idno','$dept_id','$progid','$syear','0','$lastname','$firstname','$middlename','$year','$password','$user_type')";
$result = mysql_query($sql) or die(mysql_error());
echo "<script type='text/javascript'>\n";
echo "alert('Successfully Added.');\n";
echo "window.location = 'addusers.php';";
echo "</script>";
}
?>
I need help to condition please I need help. Thanks
School_year table has(syearid(unique), from_year(2015), to_year(like 2016))