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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Location
    South-Africa
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Selected dropdownlist item - Call/Fetch data

    Hi All.

    I have a dropdown list on a web form containing dates. My Question: How can I call data for that selected item(date) from a MySQL database and display it to the user? And more specifically, if that selected date has no data in the data base, I want to be able to display that as well.
    I'm looking for a Javascript solution, and if possible a php solution.

    Thank You!

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    In your javascript code:
    1)query the value of the input date
    2)using ajax, post the value of step 1 to your php code
    3)using ajax and a callback function, retrieve the MySQL data (preferably in JSON or XML format)
    4)if a value of false is returned supplant an explanitory string into your data variable
    5)insert data into your DOM

    In your php code:
    1)test the value sent from ajax, and strip, or convert any characters that could be used to exploit security holes
    2)apply necessary conversions to the data so that it corresponds to how you structured your database
    3)connect to your MySQL to retrieve the necessary records
    4)if records are not already structured as JSON or XML, convert them to one of these formats for transmission
    5)post the record back to your ajax on the clients browser

    Your welcome
    Allwisend bin ich nicht, doch viel ist mir bewursst
    -Goethe

  • Users who have thanked blaze4218 for this post:

    DextrousDave (03-11-2012)

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Location
    South-Africa
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank You Blaze 4218, I will try it and see if I can land it.
    Appreciate


  •  

    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
    •