i have a dopdown menu which shows the list of tables in the database..now i want to dispaly the result of the selected table from the database in the dropdown menu on submit but i am unable to get how to do it,kindly help..

<?
    $link= mysql_connect("localhost","root","") or die ("could not connect");
    mysql_select_db("creative design") or die("could not Select database");

     $sql = "SHOW TABLES";
     $result = mysql_query($sql);
     $tableNames= array();

     while ($row = mysql_fetch_row($result)) {
      $tableNames[] = $row[0];
      }
      ?>

      <? echo '<select name="tables" id="tables">';     
     foreach ($tableNames as $name){
     echo '<option value="' . $name . '">' . $name . '</option>';
     }
     echo '</select>';
     ?>
     <input  name="sbtn" type="submit" value="update" />

Recommended Answers

All 2 Replies

Your code words for me.. maybe because you have a space in your database name. Can you post the full form script. So we can see what you are doing in the form.

i have removed the space from the database name.its working alright with or witout space in the database name.the options in the dropdown menu are the table names of my database "creative design".the tables of my database contains images.i want it like when i select any one of the option in the dropdown menu the images in the selected table are displayed.bt i am unable to code for it..this is the only i have done yet.kindly help me out..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.