Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Need Scripts To Display SQL Data On A Web Site

  1. #1
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need Scripts To Display SQL Data On A Web Site

    I need a script (or set of scripts) that will pull data elements from an SQL database, package them (as XML?) and push the file to a web site where the data will be displayed (probably in a table). Details: I want to retrieve incident information from a public safety database and display that information in real or near real-time on a web page. The database resides on a server inside a domain, and needs to be FTP'ed to a web site on the world wide web.

    Thanks for reading,

    Ed

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    I have managed to get data from a MYSQL database using PHP.

    I extracted all the data required into an array using PHP.

    I then converted that array into a javascript array.

    I was then able to interrogate the array for a specific element, chosen using SELECT OPTION in a form, and extract the individual fields using .split. I culd then display the individual fields for a specific MYSQL record.

    I have also used a for loop to display the elements to the screen.

    The most difficult part of this for me was converting the PHP array into a javascript array.

    If any of this would help you then let me know

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I'm learning about this as well. You don't really need JS to interpret the array; use the echo command to write your table directly from php. Start here, here, and here.

  4. #4
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    The echo command is perfect for presenting the contents of the table, however, I found that if I wanted to create the OPTIONS for a SELECT in a form, choose a record and display the details of that then using a javascript was the best way.

    This way I could retrieve all of the base data that I needed, allow a choice to be made, display and use the relevant field data and accept other input.

    I use this method when creating a HTML email, the data table contains addresses, contact details, etc for a number of companies. The selection of the company fills in certain fields, the main details of the email are entered and the email is sent.

    I use Formmail for the email, mainly because I like its validation, flexibility and most importantly - it's free

  5. #5
    Join Date
    Apr 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Site Designers

    : There are many reasons why you might like to edit your site content via the net, including ease of use, multiply editor for a site and even a single page as well as authorization of users. Luckily, there are several "Content Editor" on the market that come to the rescue, and in this post we will like to recommend Toko Content Editor.

  6. #6
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Do you have a working example I can view?

  7. #7
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    try this link, the initial PHP is to set up the OPTIONS in a select box from the contents of the table.

    It also sets up a delimited array which is then converted into a JS array.

    There is then a JS funtion which takes the selected OPTION and retrieve the relevant data from the JS array and displays the fields on the form.

    The only thing to ensure is that the first field in the array is also the field on which the PHP sort is done and that is used in setting the SELECT options.

    www.cognac-jaugeage.com/jaugeage-formmail.php

  8. #8
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Got a 404 error.

  9. #9
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    sorry, typo


    http://www.cognac-jaugeage.com/jaugeage_formmail.php

    If you look at the input field Drire the OPTIONS are populated from the database, the address details etc are populated by reading a JS array originally created by PHP.

    The HTML email is created by FormMail, a free HTML email program.

    Please don't create an email, this is a production system, ie it's live

    If this is type of thing that you want then I can send you a stripped down, reasonably commented version that does this.

  10. #10
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Not quite what I am looking for. See http://www.nashfire.org/live_inci/Incident.htm for an example.

    Ed

Bookmarks

Posting Permissions

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