jquery - Retrieving MSSQL Data In Cordova App Using PHP -


i had created simple mobile app in cordova before not have idea create database app.

here database app means create app using mssql server, html , php , had visited many sites search of proper article regarding same not find hence here present conclusion below.

this php file created text file , save .php extension.

<?php $mysql_db_hostname="myserver name"; $mysql_db_user="mee user"; $mysql_db_password="my password"; $mysql_db_database="database name";  $con = @mysqli_connect($mysql_db_hostname,$mysql_db_user,$mysql_db_password,$mysql_db_database);  if(!$con) {   trigger_error('could not connect mysql:' . mysqli_connect_error());     }  $var=array(); $sql="select * rec";  $result=mysqli_query($con,$sql);  while($obj=mysqli_fetch_object($result)) {   $var[]=$obj; }  echo '{"rec":'.json_encode($var).'}'; ?> 

this html file

<!doctype html> <html> <body> <table class="mgrid" id="jsondata"> <thead> <th>id</th> <th>name</th> </thead> <tbody></tbody> </table> <script type="text/javascript" src="jquery-1.9.1.js"></script> <script type="text/javascript"> $(document).ready (function(){ var url="getjson.php"; $(#jsondata tbody).html(""); $.getjson(url,function(data){ $.each(data.rec, function(i,recc){ var newrow= "<tr>" +"<td>"+recc.id+"</td>" +"<td>"+recc.name+"</td>" +"</tr>"; $(newrow).appendto("#jsondata tbody"); }); }); }); </script> </body> </html> 

it shows table head doesn’t shows data or sql connection error.

i want know wright way create php page text file , save on .php extension utilize in cordova retrieving data sql server?.

i not familiar of mysql use ms sql server hence if able develop mobile application using mssql server,php , html.

suggest me proper way.

use php , mssql or mysql @ backend of mobile application ie. on server side.create api's link server , mobile application. mobile application communicate server of these api's.you can request , response via api's.in of scenarios mobile application request server ajax call,do required functions in server , respond client [mobile application] in json format,the mobile application can further process returned data. cannot use server-side scripting language php inside cordova. using jquery , ajax can call php functions , data easily.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -