Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8968793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:30:12+00:00 2026-06-15T17:30:12+00:00

I’m doing an android app in eclipse (using phonegap + json + php) and

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:30:13+00:00Added an answer on June 15, 2026 at 5:30 pm

    Your form element in the HTML has no action attribute. This is where the browser will send the request when the user clicks on submit. So, if you want to send the request to your PHP script you will need you need to set that in the action attribute of your form.

    Assuming consulta.php is located in the same directory as that of your HTML page…

    <form id="combustibleForm" method="get" action="consulta.php">
            <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>
    

    Now, when this form is submitted the request will be directed to your PHP script, which will generate the JSON.

    As for getting the values sent by the form in your PHP you need to use the name attributes you defined for those SELECT elements.

    In your case that is combustibleSelect and distritoSelect.

    $_GET['combustibleSelect']; // This will be the value of the 1st SELECT box
    $_GET['distritoSelect'];    // This will be the value of the 2nd SELECT box
    

    Please do not use the old ext/mysql API to interface with your database as it has been deprecated and may be removed in future versions of PHP. Consider using the newer PDO or MySQLi APIs instead to interface with your MySQL databse in PHP.

    As for getting the data into javascript, you want to use ajax to make an XHR request to your PHP script. This will allow you to populate whatever you want to populate in the DOM of your HTML with javascript, by asking javascript to go out and make a request to your PHP script in the background and then hand you back the JSON to do with as you please without the user ever having to leave the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.