Android web app - php with local database - php

I have a very simple web page in PHP that uses a MySQL database to randomly feed a simple quiz that goes on forever as long as the user wants to keep answering questions.
I want to move this to my Android to be able to use it offline. I used jQuery Mobile to adapt the layouts to the smartphone. So now I want to move the database to a local database and remove all the need to an internet connection. I have absolutely no experience on Android development so if anyone can help me with a few questions, I'd appreciate it:
How can I store my existing database in the smartphone?
The only actions that the app performs on the database are selects. The information on the database will grow with time (not much, I just want to be able to add more records with time). Is there any tool I can use to manage the local database and add the information as I need (as I do now with PhpMyAdmin)?
The web page exists online right now, will I be able to run it locally as it is? (aka, PHP page with css and js files)
Thanks in advance.

1) Android databases are done in SQLite. I'm unsure exactly what the syntax difference between mySQL and SQLite is, but if a straight dump/import doesn't work, you could export to csv/import that way. For info on getting an external database packaged with an app, check Using your own SQLite database with Android applications. It's a very helpful guide to getting it set up.
2) I use a Firefox add-on, SQLiteManager. I hate doing it, as it's the only reason I have Firefox installed any more, but on *nix it's the best option I've found. It's either that, command line, or SQLiteMan, which I found feature-lacking. On other platforms, I can't comment.
3) I don't know if PHP has a good library for SQLite. If so, you'll most likely need to do some modification to work with that instead of mySQL. If you can get that running smoothly, you should be able to drop it into a webview. The other option is to redo it in Java.
Good luck!

Related

Real time web page update from MySQL database

Ok, so I'm in the starting stage of a new project where I have an apache web server with PHP included and a MySQL database.
The main focus aim of this project is to show data in this MySQL database as real time on the web page. The problem I have is I am not allowed to install any new software on the server, so I cannot use nodejs or socket.io
I've been looking at the PHP long polling possibility, but I'm curious if anyone out there has managed to pull off something similar without grinding their server to a halt due to too many threads being used.
I've heard about comet, but not sure how that would work as from reading it seems to just look at flat files, not databases.
Thanks for any help.
This is easily achievable with jquery and php, create a php file and echo json encoded data in return. Usage can be found here: jquery post

Should I upload PHPMyAdmin to the server

This is going to be a very stupid question. But i'm new to php and programming all together. I would be launch my first every database powered website. I'm still a student in college, so please take it easy on me.
I was using PHPMyAdmin for my local development. I'm ready now to launch the website and wanted to ask. Should I upload PHPMyAdmin together with my website? Or Not?
Thanks a million. This is an easy question for most of you but I really dont know
I say no, it can become a security vulnerability if not properly secured - but that's completely up to you. If you get yourself a good GUI mysql client you'll save yourself a lot of time anyway.
No, you should not. If you are using a shared webhosting, they normally have an internal URL where you can manage your databases using phpMyAdmin. Or if you are using your own private server, install phpMyAdmin in another location under another hostname/port, and only allow connections from your IP.

Android connection to MySQL - Php or Servlet?

This is not a codefix question but please help me where possible.
I am developing an application which needs to store information in a database. This information needs to be stored off-device for security reasons (patient data).
I have explored using PHP as a bridge to the external MySQL database hosted locally via WAMP, however I have recently been informed of servlets and also of SQLite.
As I am learning these technologies under a limited time frame I need to know which to invest my time into to get the job done as easily as possible. I have no experience with any query language but I did get a simple login screen to work on Android using PHP and MySQL on WAMP using HTTP post/fetch within android.
Also, is it possible to store the information in SQLite within android and write that data to a server, which can then load the SQLite database again on re-launch?
Many thanks for your time!
From our expericence these kind of services need to work offline if possible. Both 3g and especially wifi has been unreliable in several occasions.
You do good if you save the data locally in e.g. sqlite database but be warned the data can get wiped on OS update or software update.
Also try to write your changes/additions in batches and servr updater can send all the batches that are not yet on the server. this way it's more reliable if you miss updates.
These kind of interfaces to another systems take a lot of time in testing. Consider getting a new timeframe in advance.
You will find more about Android connection to MySQL here

Crystal reports, mysql using a php website, Is it possible?

I have been asked to find out if it is possible to connect Cyrstal Reports to a MYSQL database within a php website.
Is this possible?
Are their any alternatives
Thanks
Edit I suppose in the perfect world I am wanting to show crystal reports within a PHP website
As an alternative you can use iReport. You can use it just as you need, with a mysql database from a php website.
In response to your comment:
I would want to show CR within the PHP website
CR being a Windows executable, this will not be directly possible (aside from embedding a Remote Desktop or VNC instance, but this is probably not feasible, and would not be legal.)
Your best bet is to check whether CR has an export format that can be embedded into the web site: PDF, HTML, XML come to mind. Those you could insert into your web page manually.
If you want automated interaction between the web site's user and CR, this probably possible, but not going to be trivial. There are third party products that allow controlling CR from the command line. You may be possible to set up an interaction between PHP and Crystal Reports through the command line on a Windows server, but it's going to be a lot of work.
Your question isn't very clear, if you're trying to ask if you can connect Crystal Reports to a MySQL database (a MySQL database that is connected to a PHP site) then you might be able to, have a look at this article.
If you're tying to connection Crystal Reports to a MySQL database and embed it within a PHP application... well I'm not too sure, perhaps someone else can tackle this problem.
http://www.eakes.org/80/connecting-to-mysql-with-crystal-reports-xi/
Using Crystal Reports to generate reports from a mySQL data base works fine. Install the latest and greatest mySQL ODBC driver and just do it.
If you want to serve up pre-generated Crystal report .rpt files via a PHP-based web site, that is straightforward. You can ask your users to download the Crystal Report Viewer, and just send out those files as if they were, say, .doc or .xls files.
The viewer is here.
The tricky bit is generating Crystal files on demand. You'll need to control the Crystal instance based on input from your web site users. You'll need to ask them to wait while Crystal runs. SAP sells a server edition of their product for this purpose that works well, but it costs money.
Groff Automation makes a product called Crystal Delivery. It works well for running routine reports.

access + mysql converting to webplatform = (php + asp.net + mysql)?

i have a database that is written in access. the access mdb file connects via ODBC to a local mysql database. i have a bunch of sql and vba code in the access file. i dont expect the database to surpass 100mb. currently it is around 10mb. i will need to have multiple user access. (no more than 10 users at a time)
i need to convert this database from being a local one to a web server, and i need to make a web interface for it.
how do i get the current local instance of mysql database to run off a webserver? i am currently running it off wampserver 2.0. i dont have experience putting a database on a webserver.
i have an OK vb.net background. i have never done any web applications. here's a picture of the access form that i may need to replicate to work off a website:
alt text http://img42.imageshack.us/img42/1025/83882488.jpg
which platform should i use as the front end to this thing?
would it be possible to just run this access file off a webserver instead of programming a new front end for it? is that not a smart idea?
thank you for your help!
If your webserver has TCP connectivity to your existing database server, and its hosted in a suitable place (eg, don't have your webserver in a datacenter connecting to a database server on your office DSL connection), then no move is required.
If you do need to move it, it's as easy as creating a backup/dump, and restoring it elsewhere.
As far as the frontend, there are MANY technologies that will do what you need (ASP.NET, PHP, Python, Ruby, Perl, Java being the most popular ones, not necessarily in that order).
Use something you are comfortable with, or that you are interested in learning (provided you have the time to do so)
Use something that runs properly on your target webserver. Really, ASP.NET is the only one that has any major issue here, as it's limited to Windows.
Access itself has no direct web-accessible version. A Google search finds some apps that claim to convert Access forms to web-based, but I will not link to any because I don't know how well they work. I'm certainly leary of anything like that, because web apps are a different breed from Windows apps. If you are going to go that route, be sure they actually generate HTML output; make sane, clean source; and offer a free trial so you can verify it actually works.
Really though, a form like that is reasonably easy to reproduce with some basic knowledge of server-side programming and some HTML.
I don't have any experience migrating access to a web-based interface, although I have heard of people going straight from access to a web page. MySql is exceptionally easy to migrate. MySQL.com has a program called mysqldump that comes with the standard install of MySQL that allows you to export your database straight to a text file that can be used then with mysqldump to import it on another server. I don't believe the WAMP server comes with the command line tools although they can be downloaded from mysql.com. However, if it has phpMyAdmin, then there is also an export feature with that as well that will generate a .sql file that can be imported to the webserver using phpMyAdmin. One thing to keep in mind though is that I have had very little success mixing and matching these methods: ie, I've never been able to get a mysqldump-created file to work with phpMyAdmin and vice versa.
Good luck!
The link will help you to export and import mySQL database
May be on Windows web server there is an opportunity to run Access files, you can check, but any way if you have some programming skills, I would say that it is not difficult to crate a php script which will query your database info and will edit.
Migrating an Access application to the web is quite difficult, because you can't translate an Access form 1:1 into a web page. Web apps are stateless, whereas Access is built around the concept of bound controls and bound datasets.
Secondly, it is impossible to easily replicate an Access subform.
Third, you lose tons of events that Access forms and controls are built around.
In general, a web page that performs the same task as an Access form will bear little or no resemblance to the Access form, simply because the methods for accomplishing the same tasks and the UI widgets available to you are so completely different.
One thing to consider is whether your users need a web application or if they just need to use your existing Access application over the Internet. If the latter is the case, Windows Terminal Server/Citrix can do the job for a lot less money, since there's no conversion needed. You do need to provision a Windows Terminal Server, set up a VPN and purchase CALs for the users, but the costs of those are going to be much less than the cost of rebuilding the app for web deployment.
It may not be an appropriate solution, but it's one that you should consider, I think.

Categories