<?php
error_reporting(0);
include_once('confdb.php');
include_once('db.functions.php');
//$q = $_GET['q'];
//$result5 = mysqli_query($con,"SELECT * FROM config_states WHERE COUNTRY_CODE = '$q'");
$result5 = DB::query("SELECT * FROM config_states WHERE COUNTRY_CODE = %s", $_GET['q']);
?>

          <div class="form-group">
                          <label for="CUST_STATE">State:</label>
                              <select name="CUST_STATE" id="CUST_STATE" class="form-control">
                              <option value="0">-- Select State --</option>
                                <?php                 
                                  //while($row5 = mysqli_fetch_array($result5)) 
                                  foreach ($result5 as $row5)
                                  { 
                                ?>
                               <option value="<?php echo $row5['STATES_CODE']; ?>" <?php if ($_SESSION['CUST_STATE'] == $row5['STATES_CODE']) { echo 'selected="selected"'; } ?>>
                                <?php echo $row5['STATES_NAME']; ?>
                              </option>
                                <?php } ?>
                              </select>
                              <p class="text-danger"><small>* not required.</small></p>
          </div>


          <div class="form-group">
                          <label for="CUST_CITY">City:</label>
                          <input type="text" class="form-control" name="CUST_CITY" id="CUST_CITY" value="<?php echo $_SESSION['CUST_CITY']; ?>" required>
                          <p class="text-danger"><small>* required.</small></p>
          </div>

          <div class="form-group">
                          <label for="CUST_POSTCODE">Postcode:</label>
                          <input type="text" class="form-control" name="CUST_POSTCODE" id="CUST_POSTCODE" value="<?php echo $_SESSION['CUST_POSTCODE']; ?>" required>
                          <p class="text-danger"><small>* required.</small></p>
          </div>
