在這段代碼中,我想查詢一個名爲「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