一、学习php输出表格信息、并在表单中取值,把值传到另一个页面。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <html xmlns= "http://www.w3.org/1999/xhtml" > <head> <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <?php /*$c ="张三"; $a ="hello{$c}"; $b ='world{$c}'; echo $a."<br />"; echo $b;*/ /* function Name() { echo "aaaaaa"; } Name(); function test() { $attr=func_get_args();是获取参数,返回数组 for($i=0;$i<count($attr);$i++) { echo "第{$i}个参数是{$attr[$i]}<br />"; } } test(1,2,10,"aa");*/ /*function test($a=7,$b=8) { return $a+$b; } echo test(5,6);*/ //全局变量 /*$a=6; function test() { global $a; $a = $a+10; echo $a."<br/>"; } test(); echo $a;*/ /*$a="hello"; echo strlen($a); $b="Hello"; echo strcmp($a,$b); echo strcasecmp($a,$b); echo strtolower($b); $str="aaaaa|bbb|cccccc|dddd"; $attr=explode("|","$str"); print_r($attr);*/ /*$arr=array(); preg_match($reg,$str,$ar); preg_match_all($reg,$str,$arr); print_r($arr);*/ //例子 /*$attr = array( array("p001","张三","女","汉族","1988-2-3"), array("p002","李四","男","回族","1990-3-4"), array("p003","王五","男","汉族","1989-4-5") ); echo "<table width='100%' border='1' cellpadding='0' cellspacing='0'>"; echo "<tr><td>代号</td><td>姓名</td><td>性别</td><td>民族</td><td>生日</td></tr>"; for($i=0;$i<count($attr);$i++) { echo "<tr>"; //echo "<td>{$attr[$i][0]}</td><td>{$attr[$i][1]}</td><td>{$attr[$i][2]}</td><td>{$attr[$i][3]}</td><td>{$attr[$i][4]}</td>"; for($j=0;$j<count($attr[$i]);$j++) { echo "<td>{$attr[$i][$j]}</td>"; } echo "</tr>"; } echo "</table>";*/ ?> <form action= "one1.php" method= "get" > //需新建页面 <select id= "sel" > <?php $attr = array ( array ( "n001" , "汉族" ), array ( "n002" , "回族" ), array ( "n003" , "苗族" ), array ( "n004" , "维吾尔族" ), array ( "n005" , "朝鲜族" ) ); for ( $i =0; $i < count ( $attr ); $i ++) { echo "<option value='{$attr[$i][0]}'>{$attr[$i][1]}</option>" ; } ?> </select> <input type= "submit" id= "btn" value= "取值" /> </form> <script type= "text/javascript" > function Show() //注意函数名大小写 { var s1 = document.getElementById( "sel" ); alert(s1.value); } </script> </body> </html> |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步