仿照课堂案例,写一个简单的企业站, 并制作列表页, 详情页的模板, 注意GET参数的获取与解析,二维数组的创建是个难点,参考课堂案例去一步步完成它
实例
<?php $cates=[ ['cate_id'=>1, 'name'=> 'cp', 'alias' => '产品中心'], ['cate_id'=>2, 'name'=> 'jj', 'alias' => '解决方案'], ['cate_id'=>3, 'name' => 'sc', 'alias' => '***服务'], ['cate_id'=>4, 'name' => 'jr', 'alias' => '加入我们'], ['cate_id'=>5, 'name' => 'xz', 'alias' => '下载中心'], ]; $arr2=[ ['arr_id'=>1,'name'=>'变频器','image'=>'bpq','cate_id'=>1,'detailed'=>'变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器'], ['arr_id'=>1,'name'=>'伺服驱动器','image'=>'bpq','cate_id'=>1,'detailed'=>'伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器。'], ['arr_id'=>1,'name'=>'智能控制器','image'=>'bpq','cate_id'=>1,'detailed'=>'智能控制器智能控制器智能控制器智能控制器智能控制器智能控制器。'], ['arr_id'=>2,'name'=>'印刷包装行业','image'=>'bpq','cate_id'=>1,'detailed'=>'变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器'], ['arr_id'=>2,'name'=>'线缆线材行业','image'=>'bpq','cate_id'=>1,'detailed'=>'伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器。'], ['arr_id'=>2,'name'=>'木工***行业','image'=>'bpq','cate_id'=>1,'detailed'=>'智能控制器智能控制器智能控制器智能控制器智能控制器智能控制器。'], ['arr_id'=>3,'name'=>'售后服务','image'=>'bpq','cate_id'=>1,'detailed'=>'变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器'], ['arr_id'=>3,'name'=>'技术支持','image'=>'bpq','cate_id'=>1,'detailed'=>'伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器。'], ['arr_id'=>3,'name'=>'问题反馈','image'=>'bpq','cate_id'=>1,'detailed'=>'智能控制器智能控制器智能控制器智能控制器智能控制器智能控制器。'], ['arr_id'=>4,'name'=>'公司风采','image'=>'bpq','cate_id'=>1,'detailed'=>'变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器'], ['arr_id'=>4,'name'=>'薪酬福利','image'=>'bpq','cate_id'=>1,'detailed'=>'伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器。'], ['arr_id'=>4,'name'=>'社会招聘','image'=>'bpq','cate_id'=>1,'detailed'=>'智能控制器智能控制器智能控制器智能控制器智能控制器智能控制器。'], ['arr_id'=>5,'name'=>'应用软件','image'=>'bpq','cate_id'=>1,'detailed'=>'变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器变频器'], ['arr_id'=>5,'name'=>'宣传手册','image'=>'bpq','cate_id'=>1,'detailed'=>'伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器伺服驱动器。'], ['arr_id'=>5,'name'=>'技术文档','image'=>'bpq','cate_id'=>1,'detailed'=>'智能控制器智能控制器智能控制器智能控制器智能控制器智能控制器。'], ]; $system=['sys_id'=>1,'title'=>'深圳市海浦蒙特科技***',] //print_r($arr1); ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="<?php echo $system['title']?>"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="../static/CSS/style.css"> <title><?php echo $system['title']?></title> </head> <body> <!--网站头部--> <div class="header"> <ul class="nav"> <li><a href="index.php">首页</a></li> <?php foreach ($cates as $cate):?> <li><a href="list.php?cate_id=<?php echo $cate['cate_id']; ?>"><?php echo $cate['alias'] ?></a></li> <?php endforeach; ?> </ul>
运行实例 »
点击 "运行实例" 按钮查看在线实例
实例
<?php include __DIR__.'/header.php'; foreach ($cates as $cate){ echo "<h2>{$cate['alias']}</h2>"; echo '<ol>'; foreach($arr2 as $arr){ if($cate['cate_id']===$arr['arr_id']){ echo "<li><a href='detail.php'>{$arr['name']}</a></li>"; } } echo '</ol>'; } include __DIR__.'/footer.php';
运行实例 »
点击 "运行实例" 按钮查看在线实例
实例
<?php include __DIR__.'/header.php'; $arr3_id=intval($_GET['arr_id']); foreach($arr2 as $arr){ if($arr['cate_id']===$arr3_id){ echo "<h3>{$arr['name']}</h3>"; echo "<img src=http://www.hpmont***/Uploads/Picture/2018-11-30/5c00cd0874592.jpg'' width='400'>"; echo "<p>{$arr['detailed']}</p>"; } } include __DIR__.'/footer.php';
运行实例 »
点击 "运行实例" 按钮查看在线实例
实例
<?php include __DIR__.'/header.php'; $cate_id=intval($_GET['cate_id']); foreach ($cates as $cate){ if($cate['cate_id']===$cate_id){ echo "<h2>{$cate['alias']}</h2>"; echo '<ol>'; foreach($arr2 as $arr){ if($cate['cate_id']===$arr['arr_id']){ echo "<li><a href='detail.php?arr_id=".$arr['arr_id']."'>{$arr['name']}</a></li>"; } } echo '</ol>'; } } include __DIR__.'/footer.php';
运行实例 »
点击 "运行实例" 按钮查看在线实例
请输入描述