我正在尝试使用一个查询获取邮政编码,并将其用于另一个查询的 where 子句。
<?php
$mobile = '07790807055';
//$mobile = $_POST['mobile'];
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());
$query =("SELECT POSTCODE FROM appregistration WHERE MOBILE_NUMBER = '$mobile'");
$result = mysql_query ($query) or die ("Unable to connect. " . mysql_error());
$row = mysql_fetch_array($result);
$postcode = $row['POSTCODE'];
/// gets postcode from appregistration table
$sql=mysql_query("SELECT INCIDENT_ID, INVESTIGATION,TYPE_OF_INCIDENT,DESCRIPTION FROM appreports WHERE POSTCODE = '$postcode'");
//uses postcode from ppregistration table to find info from appreports table
while($row=mysql_fetch_assoc($sql)) $output[]=$row;
print(json_encode($output));
mysql_close();
?>