-
Notifications
You must be signed in to change notification settings - Fork 0
/
form1.php
37 lines (28 loc) · 1.01 KB
/
form1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include_once 'config.php';
if (isset($_POST['country_id'])) {
$query = "SELECT * FROM states where country_id=".$_POST['country_id'];
//$result = $db->query($query);
$result = mysqli_query($con, $query);
if ($result->num_rows > 0 ) {
echo '<option value="">Select State</option>';
while ($row = $result->fetch_assoc()) {
echo '<option value='.$row['id'].'>'.$row['name'].'</option>';
}
}else{
echo '<option>No State Found!</option>';
}
}elseif (isset($_POST['state_id'])) {
$query = "SELECT * FROM cities where state_id=".$_POST['state_id'];
//$result = $db->query($query);
$result = mysqli_query($con, $query);
if ($result->num_rows > 0 ) {
echo '<option value="">Select City</option>';
while ($row = $result->fetch_assoc()) {
echo '<option value='.$row['id'].'>'.$row['name'].'</option>';
}
}else{
echo '<option>No City Found!</option>';
}
}
?>