Blogger Information
Blog 61
fans 1
comment 0
visits 69580
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0604-PHP模板
我的博客
Original
758 people have browsed it

实例  详情页

<?php

$xq=[
    ['id'=>01,'con'=>'我是一个苹果,我很甜'],
    ['id'=>02,'con'=>'我是一个香蕉,我很香'],
    ['id'=>03,'con'=>'我是一个橘子,我很算'],
];

$id = intval($_GET['id']);
foreach ($xq as $qq) {

if($id===$qq['id']){
    echo $qq['con'];

}

    }

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例 列表页

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>列表页</title>
</head>
<body>
<?php
$list=[
    ['id'=>01,'name'=>'苹果','dj'=>2.1,],
    ['id'=>02,'name'=>'香蕉','dj'=>3.3,],
    ['id'=>03,'name'=>'橘子','dj'=>5.2,],

];
?>
<div style="width: 500px;">
<table style="color: blue;width:500px;border: 1px solid lightslategray;text-align:center;height: 100px;">
    <caption style="font-size: 30px;color:red;text-align: center;">商品名单</caption>
<thead>
<tr>
    <th>序号</th>
    <th>名称</th>
    <th>单价</th>
    <th>详情</th>
</tr>
</thead>
    <tbody>
<?php foreach ($list as $lis):?>

        <tr style='border: 1px solid red;'>

    <?php foreach ($lis as $td): ?>

      <?php  echo "<td style='border: 1px solid red;'>$td</td>"; ?>

    <?php endforeach;?>
<!--  重点:  三行循环完了在最后追加一行详情链接-->
    <?php  echo "<td style='border: 1px solid red;'><a href='xq.php?id={$lis['id']}'>详情</a></td>"; ?>
        </tr>
<?php endforeach;?>
    </tbody>
</table>
</div>

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