...

View Full Version : html5 writing to database on server



donna1
11-29-2012, 12:35 PM
Hello everyone,
I am new to this and have written a small html5 program to write a shopping list. I want to be able write my list on home or the work computer and view it from my phone or ipad later.
i have server space at 000web site and they have mysql and i have set up a table with three fields item number, product and quantity.

Is there any way html5 can read from and write to the database directly, or do I have to communicate with say a PHP server script to do that?

If i just had my shopping list stored as a text file on my server would I be able to read and write to it with html5 code directly

Thank you

sunfighter
11-29-2012, 02:02 PM
No to both questions. If your working server side you need a server side language. Even reading a text file would require something like PHP.

donna1
11-29-2012, 07:19 PM
if I write a php server based script to load the shop list into an array will my html code be able to see it? What Im asking really is if variables can be global or do I have to pass the array back as a parameter to my html5 code (if that is even possible)

I dont know anything about ajax or jquery but I read something that made me wonder if either of those could read a text file on my server, if executed from javascript in the browser??

sunfighter
11-29-2012, 10:23 PM
The php file will read your shopping list information and than generate the html page with that info embedded into it (normally as a table) that you will see in your browser. I will send you email, not today.

rnd me
11-30-2012, 12:32 AM
using javascript, you can save the info on the device, with the understanding that what's on your phone won't be the same as what's on your desktop at work...


if you want to store data centrally for many devices to use and share, you need a web server or some sort. this is not the same as a server-application. just webspace is enough to share with everyone.

you can do a half-way approach; cheap webhosting from someplace like godaddy will make text files show up at a url. you can upload these text files using ftp. once you do that, any device can READ the info using javascript.


if you want to save the info from any device, you'll need a server application.

you can use free server offerings like google spreadsheets's forms, or build a simple php relay to save the data on a server you control.

knowing your options, zoom in on what looks interesting to you and your available tools and skills, and ask here for more specific help.

donna1
11-30-2012, 11:17 AM
ok so if my shopping list is on a text file on my server what javascript command would read it from any browser?
Thanks

Philip M
11-30-2012, 12:51 PM
ok so if my shopping list is on a text file on my server what javascript command would read it from any browser?
Thanks

Google for AJAX, or use the search feature of this forum

donna1
11-30-2012, 06:44 PM
Google for AJAX, or use the search feature of this forum

is there an unthank button on this forum?
Ive tried searching for for how to open server file in html5 but to no avail. until I know what the commands called its difficult to search for it.

Philip M
11-30-2012, 07:36 PM
is there an unthank button on this forum?
Ive tried searching for for how to open server file in html5 but to no avail. until I know what the commands called its difficult to search for it.

You are not trying.

http://robertnyman.com/2010/12/16/utilizing-the-html5-file-api-to-choose-upload-preview-and-see-progress-for-multiple-files/

Search for AJAX, or new XMLHttpRequest();

rnd me
11-30-2012, 08:02 PM
is there an unthank button on this forum?
Ive tried searching for for how to open server file in html5 but to no avail. until I know what the commands called its difficult to search for it.

i used this a lot the first few months i worked in javascript:



function IO(U) {
var X =new XMLHttpRequest;
X.open( 'GET', U, false);
X.send();
return X.responseText;
}

//usage:
var url=location.href;
alert(
IO( url )
)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum