function readNew() { /*$content=file_get_contents("newest.wn"); $data=explode(";",$content); //data[0]->longitude //data[1]->latitude $data[0]=explode("=",$data[0]); $data[1]=explode("=",$data[1]); $data[2]=explode("=",$data[2]); $res[$data[0][0]]=$data[0][1]; $res[$data[1][0]]=$data[1][1]; $res[$data[2][0]]=$data[2][1]; return $res;*/ try { $pdo = new PDO("mysql:host=localhost;dbname=ncu", $user, $password); } catch (PDOException $e) { echo $e->getMessage(); } $lm = new locationManager($pdo); $all = $lm->getAll(); $newest = 0; $lat = $all[count($all) - 1]->getLat(); $long = $all[count($all) - 1]->getLong(); $res = array(); $res['longitude'] = $long; $res['latitude'] = $lat; $res['count'] = count($all) - 1; return $res; }
<?php require 'mysql/usemysql.php'; try { $pdo = new PDO("mysql:host=localhost;dbname=ncu", $user, $password); } catch (PDOException $e) { echo $e->getMessage(); } $lm = new locationManager($pdo); $all = $lm->getAll(); $newest = 0; $lat = $all[count($all) - 1]->getLat(); $long = $all[count($all) - 1]->getLong(); header('location:req.php?latitude=' . $lat . '&longitude=' . $long);