How to check if the 2 values are exist for example
=============\
idno || syearid
c23 2
c23 3
Like in the image below:
If the idno c23 exist and syearid 2 exist then it will message that this idno and syearuid exist. But when I save idno c23 and syearid 4 then it will be save because it is the same idno but not the same syearid. How should I do?
<?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');
$sql1 = mysql_query("SELECT * FROM student,school_year where idno = '$idno' AND student.syearid = school_year.syearid AND school_year.from_year like $YearNow")or die(mysql_error());
$count1 = mysql_num_rows($sql1);
if ($idno AND $YearNow == $count1 >1 ) {
echo"idno $idno has already exist with an exact current year $YearNow";
}
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'>
";
echo "alert('Successfully Added.');
";
echo "window.location = 'addusers.php';";
echo "</script>";
}
?>
