Form Hub Data Exorter - php

I have the website is hosted by Web Server. I use PHP and Mysql. And I also register and upload my data in formhub.org. Formhub allow us to export data to CSV.
My purpose, I want to automatic import the latest CSV file in Formhub or mean the latest data to my Mysql Database.
So When I upload data from Smart Phone through the customize From in Formhub.org, It will automatically update to my web base online.
How Could I do? Who can help me? Please Please give me the best solution and suggestion for this purpose.

Why not using the REST services formhub provides?
info at https://github.com/SEL-Columbia/formhub/wiki/Posting-To-External-Site
In this way, each form data is stored to your formhub and also by POST to a script anywhere you like and you can process it in your php (e.g your own mysql db).
with php you can collect the data with
$entityBody = file_get_contents('php://input');
like explained here: How to get body of a POST in php?

Related

Retrieving JSON data from WordPress mysql database to android studio directly

I'm working on a WordPress e-commerce project that need to be converted into a mobile App.
I created few custom PHP files besides regular WP files where using PHP codes I'm sending products data by JSON directly from MySQL WP database.
But I'm facing two problems here:
1) If there are more than 20 posts/products in a wp_posts table then JSON page becomes empty but if they are less than 20 then the data are passing properly.
2) I think the process is not secure because the URL which contains JSON data are publicly accessable so anyone who knows the URL of JSON page will get access all secret data like username and password.
Question 1: Is there any other way to send data from MySQL to Android except JSON, also way to restrict access to JSON URL page publicly?
Question 2: Because this is an e-commerce website so there will be more than 20k+ posts/products, so will a single JSON page be able to handle those 20k+ data? 20+ data is turning the page black currently, so how to solve those issues? Thanks a lot.

Storing and displaying data in Cordova app

I'm creating this Cordova (Phonegap) app where I store users personal data (username and scores) every 60 seconds after which I want to display all users data to everybody (like scoreboard). For this I obviously need something to first gather all the data from users and then showing it to everybody.
I tried sending data with ajax to php for database storage. Then I tried sending data with ajax to php file to write the data in file, and finally realized that ajax won't work locally(?) (yes, I'm a novice). How do I create this kind of "global memory" that is accessible by all the users? How this is normally achieved in apps? I'm open for ideas.
Thanks.
You need a backend service, and call it from your application with webservices. You should send the data to your server (via webservice), store it in a database, and generate another call to send the scoreboard to every user.
Google about Rest APIS, choose the one you like.
For storing into the app, using localstorage is OK if the data is not too big. If it is, maybe you need to use SQLite, accesible from the cordova API.

Getting data from MySQL to android and displaying as list under "App List" Tab?

I am a noob in android dev.. I have couple of questions..
1...I have database created in localhost in MySQL server. Table of all the "States".
Q2...I created PHP script to connect to the database, and getting the list from the database.. ...I need to convert this to Json file/data to be read in android...????
Q3...I created android project with tab views for list tab, getting & saving details tab, settings tab.. where details are settings tab are form view elements and need to write them back in json n send them to MySql database. how do i do that.. in php or android or both...?????
Q4.. When the user first installs the app and runs it, my app should send to the server the mobile registration id... how do it do that..?????
I tried C2DM, but no luck.. I am testing everything in the emulator first..
I am so stuck in these issues.. i have created more than 10 projects for each individual feature with the help of forums and blogs and google developer forums .. and yet dint succeed in anything..
PLZZZZZZZZZZZZZZZZZZZZZZZZZZ.... HELPPPPPPPPP!!!!!!!!!!!!?????
Thanks in adv..
Su
Q1. It is typical to use the json_encode() function to output a PHP array as a JSON object. This can be consumed by your android application by an AJAX call, passing in the URL to your PHP script.
Q2. Prepare an array of what you want to output as normal and then call json_encode() on it.
Q3. Look through the Android documentation and find a JSON encoding function. To 'send it to MySQL' you will need to pass the JSON output through an HTTP POST request to your PHP script that can validate the data and submit it to the database.

graph generation in csv file

I have generated a graph based on the user, stored in database. This graph is generating in a web page. But I am thinking to generate this graph to a csv file. But I don't know whether it is possible or not. If so, please help me out.
You can use this PHP function PHP file-put-contents()

Gears and Mysql sync

I am making an offline website that needs to sync every night with a server. Our employees work outside and sometimes underground and need to access the site for its database. But once home they must send us their findings.
The first time they connect, I check with google gears if they have the sqlite database and if not I run a script to insert it. Once they have it, I sync their next appointments to their local database.
When they are done, the next day, they connect to send us every thing and to download their new appointments.
For now i was able to create the sqllite database and insert new values inside thanks to google gears. But i haven t found a way to read the database with php to sync it with our online database.
To go from online to off, with PHP I can write an array in a hidden field and then read that field with JavaScript. But in the other way i was wondering if there was on other way then creating a form with DOM and submitting it in JavaScript to read the values with PHP?
I need to sync a Lot of values, do you know if there is an easier way?
Thanks for your help
I have found vortex, a powerfull script for gear that helps sync everything from files to data. It will definitely help me.
Here is the link to the developer's blog. The download link is in there.
I will come back when the website works to help the interested.
You should use Ajax for posting your new data to the PHP server.
You could use jquery (or any other framework), their lootle of resources how to post data to php on the web.
Your webpage could have a button hidden when offline, this button would enable user to start a synchronization.
Here a tutorial from PHP and jquery!

Categories