我正在eclipse中做一个android应用程序(使用phonegap + json + php),我遇到了一些麻烦......我真的不知道如何......
我有一个生成 json 的 php 文件(consulta.php),它位于我的服务器中(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);
因此,在我的 index.html(来自 android 应用程序,eclipse 中的 phonegap)中,有一个表单,它有 2 个选择(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>
我必须将这些选择的值传递给上面的 php 文件并从那里生成一个 json:
// 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);
这就是我要做的:在那之后......我有另一个html页面(mapa.html,在eclipse中),它从php(wtf!?)中获取json......如何做到这一点?: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