Blogger Information
Blog 19
fans 0
comment 0
visits 13576
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP基础(list模板建立,get传值)-第九期(191115作业)
feng
Original
623 people have browsed it

一、练习建立get传值,建立模板list文件。

list.php代码:

<?php
require './public/header.php';
$cate_id=intval(isset($_GET['cate_id'])?$_GET['cate_id']:'');
foreach ($cates as $cate){
    if ($cate['cate_id']==$cate_id){
        echo '<h2>' . $cate['alias']. '</h2>';
        break;
    }
}
echo '<ol>';
foreach ($movies as $movie){
    if ($movie['cate_id']==$cate_id){
        echo '<li>' . $movie['name'] . '</li>';
    }
}
echo '</ol>';
require './public/dibu.php';

 index.php代码:

<?php
require './public/header.php';
foreach ($cates as $cate){
    echo '<ol> <h2>' . $cate['alias'] . '</h2>';
    foreach ($movies as $movie){
        if ($movie['cate_id']==$cate['cate_id']){
            echo '<li>' . $movie['name'] . '</li>';
        }
    }
    echo '</ol>';
}
require './public/dibu.php';

运行结果:

1.png

2.png

 

手抄作业:

3.png

4.png

Correcting teacher:查无此人查无此人

Correction status:qualified

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