-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_city.php
72 lines (66 loc) · 2.28 KB
/
get_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
<?php
header('Access-Control-Allow-Origin: *');
include 'panel/settings/config.php';
$city_id = $_GET['city_id'];
$query = $db->prepare('SELECT * FROM plaka INNER JOIN stores ON plaka.store_id = stores.store_id WHERE plaka.plaka = ?');
$query->execute([$city_id]);
$stores = $query->fetchAll(PDO::FETCH_ASSOC);
if (count($stores) > 0) {
?>
<div class="container">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Bayi Unvanı</th>
<th scope="col">Detay</th>
<th scope="col">Çalıştığı İller</th>
<th scope="col">Maps</th>
</tr>
</thead>
<tbody>
<?php foreach ($stores as $store): ?>
<?php
$store_id = $store['store_id'];
$store_name = $store['store_name'];
$store_address = $store['store_adress'];
$lat = $store['latitude'];
$long = $store['longitude'];
$plaka_query = $db->prepare('SELECT * FROM plaka WHERE store_id = ?');
$plaka_query->execute([$store_id]);
$plakas = $plaka_query->fetchAll(PDO::FETCH_ASSOC);
$city_list = '';
foreach ($plakas as $plaka) {
$plaka_id = $plaka['plaka'];
$location_query = $db->prepare('SELECT * FROM locations WHERE plaka = ?');
$location_query->execute([$plaka_id]);
$locations = $location_query->fetchAll(PDO::FETCH_ASSOC);
foreach ($locations as $location) {
if ($location['konum_adi'] == 'İSTANBUL') {
$city_list = $location['konum_adi'];
} else {
$city_list .= $location['konum_adi'] . ' ';
}
}
}
?>
<tr>
<td><?= $store_name ?></td>
<td><?= $store_address ?></td>
<td><?= $city_list ?></td>
<td><a href="https://www.google.com/maps/search/<?= $lat ?>,<?= $long ?>" target="_blank"><img src="img/map.svg" width="20px" height="20px"></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
} else {
?>
<div class="container">
<div class="alert alert-warning" role="alert">
Bu ilde bayimiz bulunmamaktadır.
</div>
</div>
<?php
}
?>