【发布时间】:2014-06-06 18:34:38
【问题描述】:
我正在尝试解决一个 php 练习,但我不知道如何显示网站的不同部分。我知道您可以使用 switch 包含其他页面(.php)。
基本上,如果您第一次访问网站,您会看到消息:孩子们很无聊,带他们去公园(链接),点击链接后,您将进入公园视图,消息是显示有球图片和三个孩子的图片。如果您点击球,一个孩子(随机选择)将获得 1 次接球,您将被带回主页/默认视图。接球将在会话中保存,所以如果你回到公园,你会看到谁接住了球,你可以重复这个过程。你能给我一些建议吗?谢谢
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
#children {
float:left;
margin: 0px 100px;
}
#ball {
margin:100px;
}
</style>
</head>
<body>
<!-- Use this to make different page views -->
<!-- home -->
<p>Children are bored, take them to <a href="?mode=park">park</a></p>
<!-- park -->
<p>For children to be more fun, throw them a ball, you can also go <a href="?mode=home">back home</a></p>
<div id="children">
<!-- Repeat this part to make 3 children -->
<div>
<img src="child.png" alt="child" width="100"/><br/>
here child's name - here amount of balls child has caught.
</div>
<!-- end -->
</div>
<div id="ball">
<a href="?mode=throw"> <!--after throwing, add 1 catch to random child and return home page-->
<img src="ball.png" width="100" alt="ball" />
</a>
</div>
</body>
</html>
【问题讨论】:
-
我会说使用cookie而不是会话
标签: php session switch-statement case