forked from mustafakarali/ililce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
141 lines (131 loc) · 3.44 KB
/
index.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?
include("database.php");
global $db;
$db = new vt("root", "1234", "su", "localhost");
$islem = $_GET["islem"];
if($islem == "il")
{
echo '<option value="">İl seçiniz</option>';
$iller = $db->tablo("select * from il where ilID order by ad asc");
foreach($iller as $il)
{
echo '<option value="'.$il->ilID.'">'.$il->ad.'</option>';
}
}
if($islem == "ilce")
{
$id = trim(intval($_POST["ilID"]));
$ilceler = $db->tablo("select * from ilce where ilID=".$id." order by ad asc");
echo '<option value="">İlçe seçiniz</option>';
foreach($ilceler as $ilce)
{
echo '<option value="'.$ilce->ilceID.'">'.$ilce->ad.'</option>';
}
}
if($islem == "semt")
{
$id = trim(intval($_POST["ilceID"]));
$semtler = $db->tablo("select * from semt where ilceID=".$id." order by ad asc");
echo '<option value="">Semt seçiniz</option>';
foreach($semtler as $semt)
{
echo '<option value="'.$semt->semtID.'">'.$semt->ad.'</option>';
}
}
if($islem == "mahalle")
{
$id = trim(intval($_POST["semtID"]));
$mahalleler = $db->tablo("select * from mahalle where semtID=".$id." order by ad asc");
echo '<option value="">Mahalle seçiniz</option>';
foreach($mahalleler as $mahalle)
{
echo '<option value="'.$mahalle->mahalleID.'">'.$mahalle->ad.'</option>';
}
}
if($islem == "postakodu")
{
$id = trim(intval($_POST["mahalleID"]));
$postakodlari = $db->tablo("select * from postakodu where mahalleID=".$id." order by kod asc");
foreach($postakodlari as $postakodu)
{
echo $postakodu->kod;
}
}
if($islem == "")
{
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PTT İl İlçe Semt Mahalle Posta Kodu Listesi</title>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">
$.post("index.php?islem=il", function(data)
{
$("#il").html(data);
});
$(document).on('change','#il',function()
{
$("#il option:selected").each(function()
{
var istek = jQuery(this).val();
$.post("index.php?islem=ilce",{ilID: istek}, function(data)
{
$("#ilce, #semt, #mahalle, #postakodu").remove();
$("#liste").append('<p><select name="ilce" id="ilce"></select></p>');
$("#ilce").html(data).show('slow');
});
});
});
$(document).on('change','#ilce',function()
{
$("#ilce option:selected").each(function()
{
var istek = jQuery(this).val();
$.post("index.php?islem=semt",{ilceID: istek}, function(data)
{
$("#semt, #mahalle, #postakodu").remove();
$("#liste").append('<p><select name="semt" id="semt"></select></p>');
$("#semt").html(data).show('slow');
});
});
});
$(document).on('change','#semt',function()
{
$("#semt option:selected").each(function()
{
var istek = jQuery(this).val();
$.post("index.php?islem=mahalle",{semtID: istek}, function(data)
{
$("#mahalle, #postakodu").remove();
$("#liste").append('<p><select name="mahalle" id="mahalle"></select></p>');
$("#mahalle").html(data).show('slow');
});
});
});
$(document).on('change','#mahalle',function()
{
$("#mahalle option:selected").each(function()
{
var istek = jQuery(this).val();
$.post("index.php?islem=postakodu",{mahalleID: istek}, function(data)
{
$("#postakodu").remove();
$("#liste").append('<p><div id="postakodu"></div></p>');
$("#postakodu").html("Posta Kodu: "+data).show('slow');
});
});
});
</script>
<div id="liste">
<select id="il"></select>
</div>
<?php
}
?>
</body>
</html>