Results 1 to 3 of 3

Thread: PHP-SQL Dynamic pull-down menu

  1. #1
    Join Date
    Jan 2009
    Posts
    35

    PHP-SQL Dynamic pull-down menu

    Hello with all,

    I would like to make a pull-down menu which indicates the contents of a table
    It must indicate the contents of a table (namely a list of customer) or then give the possibility of returning a new customer if there does not exist yet.
    how to make?

    Thank you in advance.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: PHP-SQL Dynamic pull-down menu

    try this hope that can work
    <select>
    <?php
    $opt_str = '';
    $dirname = 'path_to_your_directory'; //
    if ($D = opendir($dirname)) {
    while (false !== ($file = readdir($D))) {
    if ($file != '.' && $file != '..') {
    $opt_str .= "<option value=\"$file\">$file</option>\n";
    }
    }
    closedir($D);
    echo $opt_str;
    }
    ?>
    </select>

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: PHP-SQL Dynamic pull-down menu

    All that should (if I did not plant myself) create you your pull-down menu with the contents of your table.
    1. <html>
    2. <body>
    3. <form action= " page_de_validation.php " method= " POST " >
    4. <SELECT name= " contained table " >
    5. <? php
    6. mysql_connect (“@serveur_sql”, “login”, “password”);
    7. mysql_select_db (“la_base_qui_contient_ta_table”);
    8.
    9. $sql = “SELECT mon_champ FROM ma_table”;
    10.
    11. $reponse = mysql_query ($sql);
    12.
    13. while ($donnees = mysql_fetch_array ($reponse)) {
    14. ? >
    15. <option value= " <? php $donnees [“mon_champ”]? > " ><? php echo $donnees [“mon_champ”]? ></option>
    16. <? php}? >
    17.
    18. <option value= " ajouter_si_manquant " >Ajouter a client</option>
    19.
    20. </form>
    21. </body>
    22. </html>

Similar Threads

  1. How to fit Push & Pull Heatsink
    By Paisley007 in forum Hardware Peripherals
    Replies: 4
    Last Post: 14-06-2012, 03:18 PM
  2. How to pull out the battery of HTC One S
    By Jon-Doy in forum Portable Devices
    Replies: 3
    Last Post: 14-04-2012, 03:58 AM
  3. Replies: 1
    Last Post: 10-03-2012, 06:58 AM
  4. Is it necessary to have push-pull w/ Sandy Bridge?
    By Sera-phina in forum Motherboard Processor & RAM
    Replies: 5
    Last Post: 09-05-2011, 05:17 PM
  5. Script to pull information from AD
    By Empurfektion in forum Active Directory
    Replies: 1
    Last Post: 30-04-2011, 03:05 AM

Tags for this Thread

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
  •  
Page generated in 1,713,582,271.63871 seconds with 17 queries