Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder donna1's Avatar
    Join Date
    Nov 2012
    Location
    london
    Posts
    99
    Thanks
    9
    Thanked 4 Times in 4 Posts

    Smile html5 writing to database on server

    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

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,180
    Thanks
    23
    Thanked 602 Times in 601 Posts
    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.

  • Users who have thanked sunfighter for this post:

    donna1 (11-29-2012)

  • #3
    New Coder donna1's Avatar
    Join Date
    Nov 2012
    Location
    london
    Posts
    99
    Thanks
    9
    Thanked 4 Times in 4 Posts
    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??

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,180
    Thanks
    23
    Thanked 602 Times in 601 Posts
    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.

  • #5
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    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.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #6
    New Coder donna1's Avatar
    Join Date
    Nov 2012
    Location
    london
    Posts
    99
    Thanks
    9
    Thanked 4 Times in 4 Posts
    ok so if my shopping list is on a text file on my server what javascript command would read it from any browser?
    Thanks

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,990
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Quote Originally Posted by donna1 View Post
    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

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #8
    New Coder donna1's Avatar
    Join Date
    Nov 2012
    Location
    london
    Posts
    99
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Philip M View Post
    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.

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,990
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Quote Originally Posted by donna1 View Post
    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/ut...ultiple-files/

    Search for AJAX, or new XMLHttpRequest();
    Last edited by Philip M; 11-30-2012 at 06:39 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #10
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    Quote Originally Posted by donna1 View Post
    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:

    Code:
    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 )
    )
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • Users who have thanked rnd me for this post:

    donna1 (11-30-2012)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •