Home  >  Article  >  Backend Development  >  How to create a drop-down list box in php

How to create a drop-down list box in php

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-09-29 10:40:564219browse

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 (&#39;../adodb5/adodb.inc.php&#39;);
  $conn = ADONewConnection(&#39;mysql&#39;);
  $conn -> PConnect(&#39;localhost&#39;,&#39;root&#39;,&#39;root&#39;,&#39;db_database14&#39;);
  $conn -> execute(&#39;set names gb2312&#39;);
  $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
?>

Related recommendations: "php Getting Started Tutorial"

select.php:

<?php
include_once &#39;conn/conn.php&#39;;
$sqlstr = &#39;select bigclass,id from tb_object&#39;;             //sql查询语句
$rst = $conn -> execute($sqlstr) or die(&#39;execute error: &#39;.$conn -> errorMsg()); //执行查询语句,返回结果集
?>
<!-- 提交表单 -->
<form method=&#39;post&#39; action=&#39;&#39;>
  请选择购买商品的类别:
<!-- 调用getMenu()函数 -->
  <?php echo $rst -> getMenu(&#39;bigclass&#39;); ?>
  <input type=&#39;submit&#39; name=&#39;submit&#39; value=&#39;提交&#39; />
</form>
<!-- ---------------- -->
<?php
if(isset($_POST[bigclass])){                    //判断表单是否被提交
  echo &#39;您选择的商品类别是:&#39;.$_POST[bigclass];         //输出提交的表单值
}
?>

2. Running results

How to create a drop-down list box in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn