You want to look into RESTful web services. Have a look at the wiki for this here. Your client's need to essentially build PHP applications that serve the underlying data of their websites through some REST-compliant data type e.g. JSON, XML, SOAP, etc. There are a number of in-built PHP functions that enable the quick conversion of PHP data structures into these formats. This would enable you to build mobile apps that make HTTP requests to get data which it can then display in it's own unique way.
An example for a JSON powered service could be as follows:
$action = $_GET['action']; switch($action) { case 'get-newest-products': echo json_encode(getNewestProducts()); break; case 'get-best-products': echo json_encode(getBestProducts()); break; . . . default: echo json_encode(array()); break; } function getNewestProducts($limit = 10) { $rs = mysql_query("SELECT * FROM products ORDER BY created DESC LIMIT $limit"); $products = array(); if (mysql_num_rows($rs) > 0) { while ($obj = mysql_fetch_object($rs)) { $products[] $obj; } } return $products; } function getBestProducts($limit = 10) { $rs = mysql_query("SELECT * FROM products ORDER BY likes DESC LIMIT $limit"); $products = array(); if (mysql_num_rows($rs) > 0) { while ($obj = mysql_fetch_object($rs)) { $products[] $obj; } } return $products; }
You could query the API as follows (with mod_rewrite on) http://myapi.mywebsite.com/get-newest-products
$.getJSON("http://example.com/db", {query: "SELECT * FROM tags"}, function(res) { });Super secure AND you get to write SQL in UI code which is great for maintainability.{query: DROP TABLE tags}? You do not EVER expose a database like that and allow direct query execution. It's about as safe as holding a gun to your head and trusting no one'll pull the trigger.