我有兩個表pre_application和申請人,我想查詢pre_application表,密碼和申請表,申請銷,如果成功的申請人應先登錄下面是我的代碼:PHP PDO查詢兩個表的差異
if(isset($_POST['submit']) || $_SERVER['REQUEST_METHOD']=='POST'){
try{
$pin=$_POST['pin'];
$pass=$_POST['password'];
$stm=$dbh->query("SELECT password FROM pre_application WHERE password='$pass' UNION SELECT app_no FROM applicants WHERE app_no='$pin'");
foreach($stm as $row);
$appass=$row['password'];
$appin=$row['app_no'];
$name=$row['name'];
if($stm) {
header('location:approfile.php?applicant=$appass');
} else {
echo "<script> alert('Invalid Application Number or Password')</script>";
exist();
}
} catch(Exception $e){
echo $e->getMessage();
}
}?>
應該有人請在正確的語法
'foreach($ stm as $ row);'停在那裏。 RTM http://php.net/manual/en/control-structures.foreach.php –
''location:approfile.php?applicant = $ appass''變量不會被單引號解析,並且POST數組未知。 –
我的問題是在查詢語法 – apollos