Dynamic html/javascript drop down list populated from MYSQL using PHP -


I think I'll have to forgive something very simple (and if I'm doing it).

I have a html doctor with a javascript in it, and in that html doctor, I would like to create a dropdown list whose value is automatically populated with the result of a mysql query.

I'm feeling that I need it to run a PHP script to get information from the database, but then how can that information be found in the dropdown is a mystery for me.

Please someone can tell me in the right direction - perhaps an example where someone has already done this.

I can not just write the dropdown in PHP because it means that I have everything else from the html page.

Many thanks,

Rob.

This is a very comprehensive question, so I'll give you a broad answer. Simple Guidelines

You have some options:

Put PPP in HTML

  • Rename your .html or your PHP Change the webserver settings (probably via HTAC if you use Apache). Give the PHP process to .html files
  • Put something in the right place in the HTML code like this:

    xy.php / html

      & lt; Choose Name = "Foss" & gt; & Lt ;? Php // php code to get data from mysql // foreach / when to do it again through the elements & quot; Option value = "'. $ Key." & Gt; ' $ Value '& Lt; / Option & gt; '; // End of Foreach / while? & Gt; & Lt; / Select & gt;   

    Use Ajax to load data

    • Leave HTML as now < Li> scripts a PHP compose dropdown output
    • Write Javascript to get the output of PHP scripts with AAGX, then insert it in the appropriate place in the DOM
    • Negative side That people without JS win

      edit: or take the view that Haza suggests

      Whatever you choose, I will are the keywords to ask to search for further questions or more questions I

Comments