Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX Autofill textfield from php array
    primarykey
    data
    text
    <p>I'm using PhoneGap to build an iPhone app, and I need to auto-fill textfields with values set on a php array through json.</p> <p>I'm having an issue figuring out how to call these values from the php file to the html file.</p> <p>The HTML page (app screen) I would like the textfields to be auto-filled for:</p> <pre><code>&lt;html&gt; &lt;div data-role="content"&gt; Fill in the following to schedule your appointment &lt;form name ="appointment "action="" method="POST"&gt; Name: &lt;input name="name" type="text" id="a_fullname" value=""&gt; Phone Numer: &lt;input name="phone_num" type="text" id="a_phone_num" value=""&gt; Email Address: &lt;input name="email_add" type="text" id="a_email_add" value=""&gt; Date For Appointment (mm/dd/yyyy): &lt;input name="appt_date" type="text"&gt; Car (Make, Model, Color and Year): &lt;input name="car_details" type="text" id="a_car_details" value=""&gt; Comments: &lt;input name="comments" type="text"&gt; &lt;input name="Submit" type="button" value="Submit"&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>Essentially, I'd like the Name, Phone Number, Email and Car details to be auto-filled by their corresponding values from the DB.</p> <p>My php page that gathers the login and basic user info is the following:</p> <pre><code>&lt;?php header('Content-type: application/json'); $server = "server"; $username = "username"; $password = "password"; $database = "database"; $con = mysql_connect($server, $username, $password) or die ("Could not connect: " . mysql_error()); mysql_select_db($database, $con); $sql = "SELECT id, uname, pword, fullname, phone_num, email_add, car_details FROM app_login ORDER BY id"; $result = mysql_query($sql) or die ("Query error: " . mysql_error()); $records = array(); while($row = mysql_fetch_assoc($result)) { $records[] = $row; } mysql_close($con); echo $_GET['jsoncallback'] . json_encode($records); ?&gt; </code></pre> <p>How should I structure the script on the html page to call these values from the specific 'id' selected through a login authentication?</p> <p>My apologies for my ignorance. I've always been very efficient with PHP, but having to use javascript as a middle man to make these apps work has been slightly confusing.</p> <p>I appreciate any help I can get.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload