summaryrefslogtreecommitdiff
path: root/loadTable.php
blob: 5497522eb45f13230184207d3211fd595d563725 (plain)
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
<?php
include 'config.php';

mysql_connect($host, $login, $pword) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

$table= $_GET["table"];

$query="SELECT * FROM ".$table;
$result = mysql_query($query);

#http://stackoverflow.com/questions/1567758/best-way-to-use-jquerys-ajax-function-retrieve-variables-from-a-php-script

$n=mysql_numrows($result);
$i=0;
$markers=array();
while ($i < $n) {
	$T=mysql_fetch_array($result, MYSQL_ASSOC);
	if (array_key_exists("id",$T)) {
		$markers[$table][$T["id"]]=$T;
	}
	else {
		$markers[$table][$i]=$T;
	}
	$i+=1;
}
mysql_close();

echo(json_encode($markers));
?>