Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to bind a list box to MySQL?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 107
    Comment on it

    We will understand the process of binding a list box to MySQL by an example. Suppose we have a database "test" having table ex1 which contains columns id,name. We need to bind the name field with the list box. For this we will use the following PHP script:

    <?php 
       $link = mysql_connect("localhost", "root", "root");//set your hostname, username and password 
       mysql_select_db("test"); 
    
       $query = "SELECT name FROM ex1"; 
       $result = mysql_query($query); 
        print "<SELECT name=item>"; 
       while ($line = mysql_fetch_array($result)) 
       { 
          foreach ($line as $value) 
           { 
             print "<OPTION value='$value'"; 
          } 
    print ">$value</OPTION>"; 
       } 
        mysql_close($link); 
    print ""; 
    ?>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: