<?php
$conn = mysql_connect ( 'localhost', 'root', 'root' );
mysql_select_db ( 'stu', $conn );
mysql_query ( 'set names UTF8' );
$sql = "select * from stu";
$query = mysql_query ( $sql );
while ( $row = mysql_fetch_array ( $query ) )
{
//第一种展示方法
//$space = str_repeat ( ' ', count ( explode ( '-', $row ['abspath'] ) ) - 1 );
//echo $space . $row ['name'] . '<br>';*/
//第二种展示方法
$space = str_repeat ( ' ', count ( explode ( '-', $row ['id'] ) ) - 1 );
@$option .= '<option value="' . $row ['id'] . '">' . $space . $row ['name'] . '</option>';
}
echo '<select name="opt">' . $option . '</select>';
?>
连接数据库option显示框
最新推荐文章于 2019-03-26 17:33:22 发布