How to retreive data from myql using php to json


#1

hey guys, am quiet ayoung programmer here down in Africa Uganda! have any one to help an african programmer, i wanted to copy with Timo’s way of displaying data with angular.js and JSONin the movie demo. now i want to retrieve data from MySQL using php to JSON, any help?


#2

Hi. Have you found a solution? If yes, can you share with me? Having the same problem. Regards!


#3

Hi all, I have noticed that many have doubts on how to send and receive data via ajax with F7, but from what I see the doubts are not only on top of F7, all requests made with the F7 request are easy to solve, practically in the request’s documentation, is clear. I’m going to leave an example code of how I use the submission. and the capture with a very simple php, the return is coming with json and everything using the post method.

$$('#my-form [name="login"]').val();
$$('#my-form [name="pass"]').val();
app.request({
    url: "http://myaddress.com/myfunction",
    method: 'POST',
    dataType: 'json',
    data: {login: login, pass: pass},
    headers: {
       //Case use Authorization set info here
       'Authorization': ""
    },
    success: function (data) {
        if (data) {
            console.log("DATA RECEIVED");
            console.log(data);
        } else {
            console.log("NOT DATA");
        }
    },
    error: function (xhr) {
        console.log(xhr);
    },
    statusCode: {
        404: function (status) {
            console.log(status);
        }
    }

});

//PHP SIMPLE EXAMPLE

if ($_POST["login"] != '' && $_POST['pass'] != '') {
    //my function to save in database
    //return array encoded
    echo json_encode(array("cod" => 1, "msg" => "success"));
}