简体   繁体   中英

Android app and iPhone app connection with PHP website

I am developing a PHP website and we want to launch mobile apps too. We are still learning. My friend, who has developed apps for Android and the iPhone , is experienced in app development but all his projects were like offline apps. He knows how to develop apps that can communicate with a server and fetch data from a server but I still want to help him. Can anyone tell me what we will need to make such an app? I know that we will need an XML script on the server to communicate with the Android app. But what we will need in the XML file to communicate with the app to fetch data from the database? I need a basic idea. Waiting for response. I use Stackoverflow to get some ideas. I always ask for ideas and basic code - not harder stuff - and I have always received great responses from you all. Thank you for helping me in advance. ;)

here is a php script I made some time ago to retrieve data from my server to an app. You put it on the server side and have your ios or android app call it from the application to get the json. Hope you find it useful!

<?php

$con = mysql_connect(yourdatabaseaddressprobablylocalhost,yourusername,yourpassword);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db(yourdatabasename, $con);


$result = mysql_query(yourmysqlquery);
while($row = mysql_fetch_assoc($result)){
    $output[]=$row;
}
print(json_encode((array('arrayname'=> $output))));

mysql_close($con);
?>

无论哪种情况,都使用 HTTP POST 和 Get 请求与 PHP 服务器和数据库通信

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM