Blogger Information
Blog 27
fans 0
comment 0
visits 22436
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
用函数方法创建表格
不乖的博客
Original
1433 people have browsed it
<?php
	$title='员工信息表';
	$arr = array(
		array(
			'id'=>1,
			'name'=>'朱一龙',
			'age' =>18,
			'sex'=>'男'
		),
		array(
			'id'=>2,
			'name'=>'般若',
			'age' =>20,
			'sex'=>'女'
		),
		array(
			'id'=>3,
			'name'=>'阿护',
			'age' =>20,
			'sex'=>'男'
		),
		array(
			'id'=>4,
			'name'=>'明玉',
			'age' =>30,
			'sex'=>'女'
		)
	);
	function CreatTable($arr){
		$res='';
		foreach ($arr as  $value) {
			$res.='<tr><td>'.$value['id'].'</td>';
			$res.='<td>'.$value['name'].'</td>';
			$res.='<td>'.$value['age'].'</td>';
			$res.='<td>'.$value['sex'].'</td>';
			$res.='</tr>';
		}
		echo $res;
	}
?>
<!DOCTYPE html>
<html>
<head>
	<title>员工信息表</title>
	<style>
			*{
				margin: 0;
				padding: 0;
			}
			table{
				widows: 400px;
				margin:100px auto;
				border-collapse:collapse
			}
			th{
				width: 100px;
				height: 30px;
				background: paleturquoise;
				border: 1px solid black
			}
			td{
				width: 100px;
				height: 30px;
				border: 1px solid black;
				text-align: center;
			}
	</style>
</head>
<body>
		<h1><?php echo $title;?></h1>
		<table cellpadding="0" cellspacing="0">
			<tr>
				<th>编号</th>
				<th>姓名</th>
				<th>年龄</th>
				<th>性别</th>
			</tr>
			<?php
				CreatTable($arr);
			?>
		</table>
</body>
</html>


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post