-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind.php
58 lines (41 loc) · 1.02 KB
/
find.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
<?php
error_log("CITTA -> " . $_POST['city'] . " , STATO -> " . $_POST['nation']);
if(isset($_POST["city"]) && isset($_POST["nation"]))
{
include 'db.php';
$citta = $_POST['city'];
$nazione = $_POST['nation'];
$query = "SELECT * FROM hmap.hospital, hmap.htype where city = '$citta' AND nation = '$nazione' AND htype.ID_htype = hmap.hospital.hospital_type";
if(isset($_POST["s"]))
{
$query = "SELECT * FROM hmap.hospital";
}
$result = mysql_query($query);
$y = 0;
$vett = array();
if($result != NULL)
{
while($row = mysql_fetch_row($result))
{
$ospedale = array();
$num_of_fields = mysql_num_fields($result);
for( $i = 0; $i < $num_of_fields; $i++)
{
$ospedale[mysql_field_name($result,$i)] = $row[$i];
}
$vett[] = $ospedale;
next($row);
$y++;
}
}
else
{
$vett[] = array('status' => 'nothing found');
}
}
else
{
$vett[] = array('error' => 'wrong post value');
}
echo json_encode($vett);
?>