Back end for phonegap

Currently from what I got after doing some research on the internet, there are a lot of languages that you can use for Phonegap app back-end, which are:

  1. PHP
  2. Java
  3. Firebase

For PHP and Java, you can use Jquery AJAX to retrieve the data from the server-side code file. For server-side code file, you are supposed to upload them on your hosting storage.

Here is one tutorial for PHP: Link 

For Firebase, you don’t need any language other than Javascript. Firebase stores data in JSON, therefore, it’s easier. No hassle. There are a lot of Firebase real-time database tutorial you can find on the Internet. Here I give you a hint what to search “Firebase Database Tutorial”. Search that and thousands of results will show up.

Here is one tutorial for Firebase that I found : Link

If you ask me which data storage strategy to use, I would recommend Firebase as there are not much of a hassle. Firebase  provide 1GB of storage for Realtime Database . As for PHP and Java, not many hosting company gives free hosting service. Therefore it costs some money especially when you are new to developing or a student.

From PHP to Javascript

From all we know, to display Javascript using PHP is very easy.

$jsInPHP = "<script>";
$jsInPHP += "alert('Hello this is in Javascript');";
$jsInPHP += "</script>";

Most of the Plugins for UI we know uses Javascript and JQuery. For example, Google’s Chart Tools. To generate the chart, we must use data. but where do we get the data? It is of course the database. To call data from database, of course we will need to use PHP. However, Javascript does not support PHP. Means that we cannot assign PHP to Javascript just like that. This is because Javascript is the client-side while PHP is the server-side. The language is different. To shorten, Javascript cannot understand PHP.

The solution to this is to use JSON. JSON is a data-interchange format. Means that JSON will translate PHP to a format where Javascript will understand it.

For example:

<?php $phpData = mysqli_fetch_row(mysqli_query($connection,"select COUNT(*) from event where YEAR(event_date)=$last3year")); ?>

var PHPinJS = <?php print json_encode($phpData); ?>;

Thats it! Good luck!