这里的PHP相当新,
我正在尝试使用php语句创建匹配的查询。该查询分布在同一数据库中的两个表中。
$check_availability = "select *
from tutors, students
where tutor_availability=student_availability";
$run_1 = mysql_query($check_availability);
if(mysql_num_rows($run_1)>0){
echo 'match found';
}else{
echo 'no match'</script>";
}
目前“if”声明的真实部分有效但“假”部分似乎不起作用。我需要确保“学生”和“导师”的“可用性”相同或不同
希望有人能指出我正确的方向?
答案 0 :(得分:0)
试试这个
$check_availability= "select *
from tutors
INNER JOIN
students
ON '$tutor_availability'='$student_availability'";
$run_1 = mysql_query($check_availability);
if(mysql_num_rows($run_1)>0){
echo 'we have a match'; //javascript
} else{
echo 'no match found'; //javascript
}
答案 1 :(得分:0)
尝试使用表格中的连接和状态列(如果有)
// my old query
//$check_availability = "select * from tutors
//join students on students.students_id = tutors.student_id
//where students.status= 'available'
//and tutors.status= 'available'"
// your original query
$check_availability = "select *
from tutors, students
where tutor_availability=student_availability";
$run_1 = mysql_query($check_availability);
if(mysql_num_rows($run_1)>0){
echo 'no match found'; //javascript
}else{
echo 'we have a match'; //javascript
}
}