I'm doing an android app in eclipse (using phonegap + json + php) and i have some troubles... I really don't know how to ...
I have a php file (consulta.php) that generates the json, whichc is locate in my server (192.168.1.200/test/consulta.php:
header('content-type: application/json'); mysql_connect("localhost","jhonatan","jsandoval"); mysql_select_db("tesis"); $array = array(); $query = mysql_query("SELECT * FROM GRIFO"); while($fila = mysql_fetch_object($query)){ //echo $fila['id'] . " " . $fila['grifo'] . " " . $fila['distrito'] . "<br/>"; $array[] = array('id'=>$fila->id, 'grifo'=>$fila->grifo, 'distrito'=>$fila->distrito, 'latitud'=>$fila->latitud, 'longitud'=>$fila->longitud); } echo json_encode($array);
So, in my index.html (from android app, phonegap in eclipse) , have a form wich gets 2 selects (HTML).
<form id="combustibleForm" method="get">
<select id="combustibleSelect" name="combustibleSelect" data-theme="a">
<option value="gnv" >Gas Natural Vehicular</option>
<option value="glp" >Gas Licuado de PetrĂ³leo</option>
</select>
<br/>
<select id="distritoSelect" name="distritoSelect" data-theme="a">
<option value="SJL" >San Juan de Lurigancho</option>
<option value="Miraflores" >Miraflores</option>
<option value="Chorrillos" >Chorrillos</option>
<option value="Surquillo" >Surquillo</option>
</select>
<br/>
<input type="submit" data-role="button" id="continuarBtn" value="Continuar.." />
</form>
I must pass the values of these selects to the php file above and generate a json from there:
// GET THE VALUE OF THE SELECTS ... I don't know if this is correct? :S
$tipo = $_GET['tipo'];
$distrito = $_GET['distrito'];
...
...
$query = mysql_query("SELECT * FROM GRIFO WHERE (tipo='$tipo' and distrito='$distrio')");
...
...
// Generate json
echo json_encode($array);
This is what i have to do: After that... i have another html page (mapa.html, in eclipse), that get the json from the php (wtf!? ) ... HOW TO DO THIS? :S ..
Also, when i Click the submit form (in index.html), must redirect to mapa.html , to get the json....
I really don't know and don't have any ideas to do this big problem...
Can someone please help me?...
Sorry for bad english
mysql_
family of functions. Now would be a great time to switch to PDO or mysqli. – Charles Dec 9 '12 at 22:20