Retrieving mysql data using json and php

any tutorials or sample project that retrieves data from mysql using php and json??

php isn’t my strong point, but thankfully a lot of people out there have put examples together. Now it’s not specific to ionic, but it is angular so it shouldn’t but to much different.

Hi Ernie_Mac

I’ve built an Ionic project on the same technologies.

If you need any specific examples maybe drop me a message and I’ll see if I can help you out? Or if you’d prefer, post some more specific questions here and I’ll do my best to answer and then hopefully people in future can benefit :smile:


Hi I am trying build a login, signup forms that links to mysql to save and retrieve user information and as well as creating user profiles for each registered user…

also building a daily deals app that retrieves all the deals stored in the database with view page to display more information for a specific deal when the user clicks…

am kinda new to ionic so if you know any tutorials or project with similar functionalities I would appreciate the help.


Ionic leverages AngularJS. So where you’d probably need to start is looking into Angular factories and the HTTP service.

YourModule.factory('fctryRegister',['$http', function($http)
  return {
    submitRegistration: function(userName, userEmail, userPhone, successcb) {
      var RegObj = {};
      RegObj["SP_Name"] = "prc_user_reg";      
      RegObj["userName"]= userName;
      RegObj["userEmail"]= userEmail;
      RegObj["userPhone"]= userPhone;
      $'pathToYourPHP.php', RegObj)
          .success(function (data, status, headers, config) 
          .error(function (data, status, headers, config) 
                  alert("Oops something went wrong. Please login and try again. Sorry for the inconvenience.");               

So basically we have an Angular factory attached to my Angular module. I have a PHP page which I pass a stored procedure name as well as an array of parameters. Inside the PHP I strip out the parameters and pass them to the relevant stored procedure and return a result.

That result is stored in the data variable of the success method.

This example makes use of a callback which is passed to the factory, calling this from my controller would look something like this:

fctryRegister.submitRegistration($scope.userDetails.userName, $scope.userDetails.userEmail, $scope.userDetails.userPhone, function(uID)


function(uID) is the callback being passed to the factory. uID will hold the data passed back from the factory.

There may be other ways or better ways to do this, but it’s how I’ve built my app, works pretty well :smile:

Let me know if I can help with anything else!

1 Like

Did you have any joy with this Ernie??


Hi Ed,

I am Dennizh, nice to meet you…
I am newbie here and the problem was same like ernie, to retrieve data from my website that running on apache.

Did you have any blog or reference that write step by step to connect ionic with mysql on www (php) url (just sample only)

Thanks for your helps…

It’s not so simple, because you can also need to check if connection is available and fall back if connection isn’t available.

However, google can help you, for example:

Hi Fabio,

Thanks for the link, now I will try to view the json on the web to android app

Hello @edwrede_ZA,
please can you send me your example project?