Home > Article > Backend Development > How to create a drop-down list box in php
The example in this article describes the function of PHP ADODB to generate a drop-down list box. Share it with everyone for your reference, the details are as follows:
1. Code
adodb.inc.php can be obtained from the official website http://adodb.sourceforge.net/ download.
conn.php:
<?php include_once ('../adodb5/adodb.inc.php'); $conn = ADONewConnection('mysql'); $conn -> PConnect('localhost','root','root','db_database14'); $conn -> execute('set names gb2312'); $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; ?>
Related recommendations: "php Getting Started Tutorial"
select.php:
<?php include_once 'conn/conn.php'; $sqlstr = 'select bigclass,id from tb_object'; //sql查询语句 $rst = $conn -> execute($sqlstr) or die('execute error: '.$conn -> errorMsg()); //执行查询语句,返回结果集 ?> <!-- 提交表单 --> <form method='post' action=''> 请选择购买商品的类别: <!-- 调用getMenu()函数 --> <?php echo $rst -> getMenu('bigclass'); ?> <input type='submit' name='submit' value='提交' /> </form> <!-- ---------------- --> <?php if(isset($_POST[bigclass])){ //判断表单是否被提交 echo '您选择的商品类别是:'.$_POST[bigclass]; //输出提交的表单值 } ?>
2. Running results
The above is the detailed content of How to create a drop-down list box in php. For more information, please follow other related articles on the PHP Chinese website!