-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare_city.php
74 lines (66 loc) · 1.49 KB
/
prepare_city.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$conn=mysqli_connect("localhost","root","","aromafeeds");
if(!$conn){
die("Database successfully connected");
}
$sql="SELECT City FROM cities WHERE States=?";
$city="";
$stmt= $conn->prepare($sql);
$stmt->bind_param("s", $_GET['q']);
$stmt->execute();
//$stmt->store_result();
$stmt->bind_result($city);
//$result=$stmt->get_result();
//while($city=$result-> fetch_array(MYSQLI_ASSOC){
// print $city[0]."<br>\n";
//}
echo "<option>Choose..</option>";
while($stmt->fetch()){
echo "<option>".$city."</option>";
}
$stmt->close();
?>
/*$result=mysqli_query($conn, $sql);
$city[]="";
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
$city[]=$row['City'];
}
}
foreach($city as $c){
echo $c;
}
$q=$_REQUEST["q"];
*/
/*
$city[]="";
$stmt=mysqli_prepare($conn, $sql);
if($stmt){
mysqli_stmt_bind_param($stmt, "s", $c);
$c=trim($_POST['state']);
//Try to execute this statement
if(mysqli_stmt_execute($stmt)){
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt)>0){
while($row=mysqli_stmt_fetch($stmt)){
$city[]=$row['City'];
}
}
else{
echo "City Data not available";
}
foreach($city as $ci){
echo $ci;
}
}
else{
echo "Something went wrong";
}
}
mysqli_stmt_close($stmt);
*/
<!--
<form action="" method="post">
<input type="text" name='state'>
<input type="submit">
</form>