2021-10-08

导入命令

1.四个导入命令 include include_once require require_once;

include('data.php');
//require 'data.php';
// include_once'data.php';
// require_once'data.php';
// var_dump($allStudents);

//查看有多少个
$count=count($allStudents);

作业

效果图

在这里插入图片描述

代码

<DOCTYPE <!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
<?php include('data.php');?>
  <table>
  	<thead>
  		<tr>
  			<td class="t1">序号</td>
  			<td class="t1">学号</td>
  			<td class="t1">姓名</td>
  		</tr>
  	</thead>

  	<thead  class="biao1" style="text-align: center;">
      <?php  foreach ($allStudents as $k => $v) :?>
      	  <?php if ($k%2) :?>
      	<tr class="trbgc" >
      	 <td class="b1"><?php echo $k+1 ;?></td>
      	 <td class="b2"><?php echo $v['sno']; ?></td>
      	 <td class="b3"><?php echo $v['name']; ?></td>
        </tr>
    <?php else :?>
    	<tr >
      	 <td class="b1"><?php echo $k+1 ;?></td>
      	 <td class="b2"><?php echo $v['sno']; ?></td>
      	 <td class="b3"><?php echo $v['name']; ?></td>
        </tr>

       <?php endif ?> 

      <?php endforeach?>

  	<thead>

  	<tfoot>	
  	</tfoot>

  </table>
  <style type="text/css">
       .trbgc{
       	background-color: #ddd;
       }
       .b1{
       	width: 50px;
      }
      .b2{
      	width: 200px;
      }
      .b3{
      	width: 100px;
      }
      .t1{background-color: #dcd;
         height: 40px;
         text-align: center;
      }

  </style>

</body>
</html>
<?php 
$allStudents=[
['name'=>'张晓斌',	'sno'=>'20191440854'],
['name'=>'丁治程',	'sno'=>'20191440408'],
['name'=>'高一博',	'sno'=>'20191440807'],
['name'=>'侯思健',	'sno'=>'20191440210'],
['name'=>'黄书傲',	'sno'=>'20191440211'],
['name'=>'季观珲',	'sno'=>'20191440811'],
['name'=>'李元利',	'sno'=>'20191440419'],
['name'=>'李月',	'sno'=>'20191440820'],
['name'=>'连孟扬',	'sno'=>'20191440220'],
['name'=>'刘捷',	'sno'=>'20171080216'],
['name'=>'满正阳',	'sno'=>'20191440829'],
['name'=>'孟兆飞',	'sno'=>'20191440227'],
['name'=>'牛纪旺',	'sno'=>'20191440423'],
['name'=>'秦晓枫',	'sno'=>'20191440334'],
['name'=>'尚荩',	'sno'=>'20191440228'],
['name'=>'孙路发',	'sno'=>'20191440230'],
['name'=>'孙祥凯',	'sno'=>'20191440429'],
['name'=>'王思雨',	'sno'=>'20191440236'],
['name'=>'王腾宇',	'sno'=>'20191440237'],
['name'=>'闫庚',	'sno'=>'20191440846'],
['name'=>'杨淼',	'sno'=>'20191440847'],
['name'=>'杨明伟',	'sno'=>'20191440342'],
['name'=>'张金龙',	'sno'=>'20191440346'],
['name'=>'张仁福',	'sno'=>'20191440850'],
['name'=>'张朔',	'sno'=>'20191440851'],
['name'=>'张学英',	'sno'=>'20191440348'],
['name'=>'赵敏',	'sno'=>'20191440247'],
['name'=>'赵文鑫',	'sno'=>'20191440248'],
['name'=>'董磊',	'sno'=>'20191440205']

]

 ?>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值