邮政编码和检索它们

In this code I want to query a table called "zipcodes". I want to first check to see if the zip code entered is a valid zip code. Then if it is a valid zip code I want to retrieve that zip code with the matching longitude, latitude, city, & state.

Then after retrieving them I want to place them into another table called "Users". Once in Users table I want to be able to pull the values that are assigned to them to echo in various places on my website.

 <?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"', "'")) {


    {


    }   


    ?>

This is a quick review of your code. There is no other answer to be made here. My comments begin with // :. I've fixed up the basic syntax and indented the code to make it readable.

<?php

$query = mysqli_query($con, "SELECT * FROM zipcodes WHERE ZIP='".$user_zip."'");

// : Checking if there are 0 or more rows returned.
if(mysqli_num_rows($query) > 0) {
    echo "Please Reenter A Valid Zip Code";
// } << : Need a closing bracket here.

{ // : These curlies must be for decorative purposes?
}

// : "If 0 or more rows; else if 1 or more rows". 
// : This'd never run because a previous condition matches; 1 > 0!
elseif(mysqli_num_rows($query) > 1) {
    mysqli
    // Need to put next line of code in users db
}

// : You already matched the > 1 condition above. + syntax error!
elseif (mysqli_num_rows($query) > 1($con, "INSERT INTO ")) {

// : Fixing that syntax. You probably meant something like:

elseif (mysqli_num_rows($query) > 1) {
    mysqli($con, "INSERT INTO [...] ");
}

// : This is totally garbled up, both the PHP and the SQL query:

// 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"', "'")) { 
*/

// : You probably meant something like:

elseif ($user_zip == true) {
    $query = mysqli_query($con, 
        "SELECT * FROM zipcodes 
            WHERE ZIP='{$zip}' 
                AND Latitude='{$latitude}' 
                AND Longitude='{$longitude}' 
                AND City='{$local}' 
                AND State='{$country}'");
}

No magic in the world would make this work -- even with all the syntax corrected. I'd recommend you first spend a bit of time learning PHP (and MySQL) syntax. Then think through the logic of what you want to do. Then try to express that in your code. Start with writing test code for the most simple things. Then work your way up to more complicated stuff. Good luck and happy learning.