facebook

Adding dynamic content from a MySql database to an app

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #338268 Reply

    trablus
    Member

    I am devleoping a mobile app for iOs using MobiOne, it will basically be an app version of this website: http://www.tripolirestaurant.com/. So far I have been able to make a really nice design and have implemented it nicely using MobiOne. I have now hit a wall on a page I am developing for this app which involves loading dynamic content from a database. On my website I use php for this functionality, see here: http://www.tripolirestaurant.com/appetizers.php

    I have been searching through the forums and on Google to find out how to load dynamic content in my app. I know html5 can’t connect directly to a database. What do you suggest I do in order to load the list of appetizers in my example above, from a database? I tried using the html widget then using an iFrame to display a php page hosted on my servers, but that is not a very elgant solution, as it adds a scroll bar on the right of the iPhone screen, which I do not want. Also I read on the MobiOne site a warning about iFrame issues with iOs and Safari. Is it possible to use a javascript function to read from a MySql database then load that the data into an xml file which could then be used to feed the data to my html5 page? I am open to suggestions, this is the first app I am developing, but I have been developing websites for 15 years now.

    Thank you

    #338275 Reply

    Yann
    Member

    Hello trablus,
    why use XML to display HTML data?
    you can directly use jquery $ajax function to call your remote php page and put it in a div inside html widget.

    Yann

    #338384 Reply

    trablus
    Member

    Thanks Yann. Does that mean I should have a PHP page already set up on my server similar to http://www.tripolirestaurant.com/appetizers.php minus the web page formatting?

    #338385 Reply

    Brandon
    Member

    As long as its formatted correctly you might not need any modification. Its easy to load an external file:

    <div id=”success” width=”100″ height=”100″></div>//add percent sign board wont allow them
    <script>
    $(“#success”).load(“demo.html”);//load html page
    </script>

    You might be able to setup a box to add a variable to your page call to call the php file
    $(“#success”).load(“menu.php?” + myid);

    #338387 Reply

    trablus
    Member

    Thanks, but that didn’t seem to work, tried both a relative path to a php page and one linking directly to my server:
    <div id=”success” width=”100″ height=”100″></div> //percentages removed, board doesn’t allow
    <script>
    $(“#success”).load(“app_appetizers.php”);//load php page
    </script>

    And this:
    <div id=”success” width=”100″ height=”100″></div> //percentages removed, board doesn’t allow
    <script>
    $(“#success”).load(“http://www.tripolirestaurant.com/appetizers.php&#8221;);//load php page
    </script>

    Is there another way to do this? Should the php page be in a local folder with the *.mobi files?

    #338394 Reply

    Yann
    Member

    Hello Trablus

    your URL http://www.tripolirestaurant.com/appetizers. php return a 404 because you have a space between . and php.
    Take a look also about Access-Control-Allow-Origin
    https://www.google.fr/search?q=PHP+Access-Control-Allow-Origin
    Yann

    #338415 Reply

    trablus
    Member

    I verified that there are no spaces between . and php. That must have been inserted on this board.
    I will take a look at the link you sent me, thank you.
    Do you know if i should be using the full link http://www.tripolirestaurant.com/appetizers.php in my code? When I do and build in MobiOne, it freezes and I have to force close it, so I am asuming it doesn’t like it when I use the full url. If I put in a local path it doesn’t crash but nothing appears in the html widget where I placed the code.

    #338416 Reply

    Brandon
    Member

    Php files will not render on devices only usable on a web app. You would need to use the full url to pull it from the server.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Adding dynamic content from a MySql database to an app

You must be logged in to post in the forum log in