在这段代码中,我想查询一个名为“zipcodes”的表。我想首先检查输入的邮政编码是否是有效的邮政编码。那么如果它是一个有效的邮政编码,我想检索与匹配的经度,纬度,城市,&状态的邮政编码。邮政编码和检索它们
然后,在检索它们之后,我想将它们放到另一个名为“Users”的表中。一旦进入Users表,我希望能够将分配给它们的值在我的网站上的各个位置进行回显。
<?php
$query = mysqli_query($con, "SELECT * FROM zipcodes WHERE ZIP='".$user_zip."'");
if(mysqli_num_rows($query) > 0){
echo "Please Reenter A Valid Zip Code";
{
}elseif(mysqli_num_rows($query) > 1){
mysqli
// Need to put next line of code in users db
}elseif (mysqli_num_rows($query) > 1($con, "INSERT INTO ")){
// retrieve from the database the city and state
}elseif ($user_zip == true($query = mysqli_query($con, "SELECT * FROM zipcodes ZIP,Latitude,Longitude,City,State WHERE ZIP='".$zip.", Latitude='".$latitude"', Longitude='".$longitude"', City='".$local"', State='".$country"', "'")) {
{
}
?>
只需在用户表中存储zip记录的'id'即可。然后在需要位置信息时进行“加入”。也使用参数化查询。这将开放给SQL注入(可能) – chris85
首先修复无意义的代码。此代码必须产生错误 – RiggsFolly
@RiggsFolly你的意思是“废话”,虽然+1 – JBES