So I'm really new to it, I work with HTML5 with the webview class to work on HTML5 new project code in android studio I have created a database with phpmyadmin and I have created a search engine php to get data from the database. My project is actually about adding Android apps to the database, which has a list of products like Catalog, in the end it should be able to get each record individually and allow user feedback. With all I have found at that point that I do not know how can I connect Android application with the database using all PHP codes which I had created as the first searcher (with modifications or something else) . As I said, I am new to all this, so I do not know that using Webview to bring a search application built with PHP can be considered right in the Android application project, the key factor in the school project issue.
Edit * Now I have this:
$ isbn, 'titol' = & gt; $ titol, 'autor' => $ autor, 'any' = & Gt; $ any, 'descripcio' = & gt; $ descripcio, 'format' = & gt; $ format); } // DebonicTamos La Base Day Data $ close = mysqli_close ($ inclusion) or die ("Hysteistida and unbidden and la destion de la bas de data"); $ Json_string = json_encode ($ registres); Echo $ json_string; ? & Gt;
But the system gives the following:
Notice: Undefined index: In Input: \ xampp \ htdocs \ json4 \ api \ api3.php line 13
You can run PHP code in WebView. But you can use HTML5 and Javascript to connect to the database,
- First you need to create an API, search for it. Create a page called FOPY and host your server like . Www.yourdomain.com/search.php
- Now to connect the database and get results from mysql, there is search.php code, keep them in array and finally JSON as output.
Search.php
& lt ;? Php $ con = mysql_connect (host, user, pass); $ Input = $ _ request ['input']; $ Sql = "Select * From the table where the field =". $ Input; // change table and field $ result = mysql_query ($ sql, $ con); $ Rows = array (); While ($ line = mysql_fetch_array ($ result)) {$ rows [=] $ line; } Echo json_encode ($ rows); // It results in the form of JSON? & Gt;
// Now your Android application can use AJAX calls using Javascript to request URL, use JQUERY mobile for easy AJAX calls www.yourdomain.com /search.php?input=some + text
and AJAX calls returns JSON data that can be parsed and displayed in the webview.
No comments:
Post a Comment