作业:------数据库下拉菜单,数据库复选框
$attr = array(
array("n001","汉族"),
array("n002","回族"),
array("n003","苗族"),
array("n004","维吾尔族"),
);
1.要求用下拉列表的样式显示在页面上
2.要求用checkbox/radio 列表 显示在页面上
1.要求用下拉列表的样式显示在页面上
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>数据库下拉菜单</title> 6 </head> 7 8 <body> 9 10 <select size="1"> 11 12 <?php 13 $attr=array( 14 array("n001","汉族"), 15 array("n002","回族"), 16 array("n003","苗族"), 17 array("n004","维吾尔族"), 18 ); 19 foreach($attr as $v) 20 { 21 echo"<option>{$v[0]}{$v[1]}</option>"; 22 } 23 24 25 ?> 26 27 28 </body> 29 </html>
显示结果:
2.要求用checkbox/radio 列表 显示在页面上
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>数据库复选框</title> 6 7 </head> 8 9 <body> 10 11 <?php 12 $attr=array( 13 array("n001","汉族"), 14 array("n002","回族"), 15 array("n003","苗族"), 16 array("n004","维吾尔族"), 17 ); 18 foreach($attr as $v) 19 { 20 echo"<input type=checkbox>{$v[0]}{$v[1]}.<br>"; 21 } 22 23 ?> 24 </body> 25 </html>
显示结果: