zoukankan      html  css  js  c++  java
  • 一、学习php输出表格信息、并在表单中取值,把值传到另一个页面。

    <!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>
    

      

  • 相关阅读:
    repeater嵌套RadioButtonList赋值
    hive表导出到mysql报错
    hive创建表时报错
    linux————mysql————修改密码
    Spark入门:Spark运行架构(Python版)
    1、Spark简介(Python版)
    使用蒙特 ·卡罗方法计算圆周率近似值
    python运算符,内置函数简单使用
    numpy、pandas、scipy、matplotlib、jieba、 openpyxl、pillow的安装
    XML详解
  • 原文地址:https://www.cnblogs.com/as1234as/p/5504256.html
Copyright © 2011-2022 走看看