我现在碰到这样一个问题:在index.php中有1000个链接,ID分别从1,2,3...1000。
所有链接的网址也就是index.php?ID=1, index.php?ID=2 ... index.php?ID=1000(方法 2) 。
这1000个链接网页中有一部分内容是重复的。最简单实现的办法是方法 1 :
建1000个文件:
ID=1.php ,ID=2.php ,ID=3.php ,ID=1000.php。
但是很显然 方法 1 这样做非常多的代码会重复,导致一个很简单的网页最后代码有20M。
现在我想问的是如何实现index.php?ID=1, index.php?ID=2 ... index.php?ID=1000 这样一种方法来避免重复。
请问谁能不能类似的源代码可供参考一下?
还有一个问题就是如果实现了方法 2 ,那么这1000个网页文件中不同的内容该怎么存放?存放在哪里? 谢谢!!!
所有链接的网址也就是index.php?ID=1, index.php?ID=2 ... index.php?ID=1000(方法 2) 。
这1000个链接网页中有一部分内容是重复的。最简单实现的办法是方法 1 :
建1000个文件:
ID=1.php ,ID=2.php ,ID=3.php ,ID=1000.php。
但是很显然 方法 1 这样做非常多的代码会重复,导致一个很简单的网页最后代码有20M。
现在我想问的是如何实现index.php?ID=1, index.php?ID=2 ... index.php?ID=1000 这样一种方法来避免重复。
请问谁能不能类似的源代码可供参考一下?
还有一个问题就是如果实现了方法 2 ,那么这1000个网页文件中不同的内容该怎么存放?存放在哪里? 谢谢!!!
像index.php?ID=1 这样子 一般只是在index.php页 取id这个参数来对数据库中的表 查询数据
id=1 只是一个条件
<body>
<div id="div_download">
<?php
@ $db=new mysqli('localhost','gameload','gameload123','game'); //实例化对象,建立连接
$db->query("set names 'GBK' ");if(mysqli_connect_error()) //检测连接是否有误
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "SELECT * FROM basic"; $result=$db->query($query);$num_result = $result->num_rows;
echo "<p><strong>游戏下载</strong></p>";
for($i=0;$i<$num_result;$i++)
{
$row=$result->fetch_assoc();
echo "<a href='MYgamedownload.php?id=" . $row['id'] . "'>" . $row['title'] . "</a><br />"; echo "</br>";
}
?>
</div>
<?php
$result->free();
$db->close();
?>
</body>
</html>对应的MYgamedownload.php如下:
<body>
<?php@ $db=new mysqli('localhost','gameload','gameload123','game'); //实例化对象,建立连接
$db->query("set names 'GBK' ");
if(mysqli_connect_error()) //检测连接是否有误
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
} $id=$_GET['id']; //这句接受了参数 id $query = "SELECT * FROM `basic` WHERE id =".$id;
$result=$db->query($query); $row=$result->fetch_assoc();
echo "<div id='download_title'>";
echo '可套用主页面的title、bottom';
echo "</div>";
echo "<div id='download_image'>";
echo "<img src='".$row['img_path']."' alt=".$row['title']." />";
echo "</br>";
echo "</div>"; echo "<div id='download_information'>";
echo "<p><strong>";
echo htmlspecialchars(stripslashes($row['title']));
echo "</strong></P>"; echo "<p>".'游戏语言:'.htmlspecialchars(stripslashes($row['language']))."</P>"; echo "<p>";
echo '运行环境:';
echo htmlspecialchars(stripslashes($row['platform']));
echo "</P>"; echo "<p>";
echo '游戏大小:';
echo htmlspecialchars(stripslashes($row['size']));
echo "</P>";
echo "<p>";
echo '游戏简介:';
echo htmlspecialchars(stripslashes($row['describe']));
echo "</P>";
echo "</div>";
echo "<div id='download_adress'>";
echo "<p>";
echo "<a href=".$row['src_path']. "><strong>立即下载</strong></a>";
echo "</P>";
echo "</div>";$result->free();
$db->close();
?>
</body>
</html>