diff options
| author | Comment <tim@gray.(none)> | 2013-05-08 22:59:04 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-05-08 22:59:04 +0100 |
| commit | 4f81e9399051cc90ccddeb69b785d7422a28a1ff (patch) | |
| tree | ea5187184ed61114b9315371e5c2d709bdf26c4f /loadTable.php | |
initial commit
Diffstat (limited to 'loadTable.php')
| -rwxr-xr-x | loadTable.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/loadTable.php b/loadTable.php new file mode 100755 index 0000000..5497522 --- /dev/null +++ b/loadTable.php @@ -0,0 +1,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)); +?> |
