getList implemented

This commit is contained in:
Daniel Løvbrøtte Olsen 2016-05-15 18:11:22 +02:00
parent bd3caacbdc
commit 017d096ff5

View File

@ -53,6 +53,12 @@ if (!TableExists($config["db_table"], $conn)) {
<input type="submit"> <input type="submit">
</form> </form>
<?php
$list = getList($conn, $config["db_table"]);
print_r($list);
?>
</body> </body>
</html> </html>
@ -70,9 +76,25 @@ function addToTable($lat, $lon, $url, $table, $conn) {
settype($lon, "double"); settype($lon, "double");
$sql = "INSERT INTO `" . $table . "` (`id`, `location`, `url`, `date_added`) VALUES (NULL, GeomFromText('POINT(" . $lon ." " . $lat . ")',4326), 'test', CURRENT_TIMESTAMP)"; $sql = "INSERT INTO `" . $table . "` (`id`, `location`, `url`, `date_added`) VALUES (NULL, GeomFromText('POINT(" . $lon ." " . $lat . ")',4326), 'test', CURRENT_TIMESTAMP)";
//$sql = mysqli_real_escape_string($conn, $sql); //$sql = mysqli_real_escape_string($conn, $sql);
printf($sql); //printf($sql);
$res = mysqli_query($conn, $sql); $res = mysqli_query($conn, $sql);
($res) ? printf("true") : printf("false"); ($res) ? printf("true") : printf("false");
} }
function getList($conn, $table) {
$sql = "SELECT * FROM `$table`;";
print_r($sql);
$res = mysqli_query($conn, $sql);
($res) ? printf("true") : printf("false");
$list = array();
while($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$list[] = $row;
}
return $list;
}
?> ?>