Share on Google+Share on Google+

PHP list box mysql

In this part of the PHP tutorial, we will learn how to use List Box in the form. The values in the PHP List Box is retrieved from database and filled in the box.

  • PHP List box that displays the data from mysql table.
  • User can select any value from the PHP list box.

Example of PHP MYSQL List Box


$chandle = mysql_pconnect("localhost", $username, $password)
  or die("Connection Failure to Database");
mysql_select_db($database, $chandle) or die ("Database not found.");

$query1="select * from stud where roll='$roll1'";

     $f1 = mysql_result($result,$x,1) or die("Failed Query");
    echo "name is ".$f1;

Select the roll <form action='<?php echo $_SERVER['PHP_SELF'];?>'>
select name='roll' size="10">
option value=1>1</option>
option value=2>2</option>
option value=3>3</option>
option value=4>4</option>
option value=5>5</option>
option value=6>6</option>
option value=7>7</option>
option value=8>8</option>
option value=9>9</option>
option value=10>10</option>
input type="submit">


name is johan


Posted on: October 31, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.