所以基本上我想要的是这样一个网站:
Name:
Date:
(picture of person)
但我不想为每个人(成千上万的人)手工创建一个新页面。我拥有数据库中所需的所有内容。有没有办法让我点击上一页表格中的人名,并让它生成一个包含该人内容的页面?
类似于:
<html>
<head>
<title>Display User</title>
</head>
<body>
<?php
// Write all the queries here, by using $_GET to fetch the content
// from the url. You might also want to include the user id in the url.
// Finally, fetch the rows as $row = ...
?>
Name: <?php echo $row['name']; ?><br /><br />
Date: <?php // Do what you want with the date here ?><br /><br />
<img src="<?php echo $row['imglocation']; // Change this parameter to fit your needs" />
</body>
</html>
基本原则是向数据库请求每个带有ID的记录。所以URL可以是person.php?id=xxx,其中xxx是与数据库记录相对应的id。
然后在person.php中,您将使用$_GET['id']从DB中获取正确的记录。当然,您需要转义输入以保护数据库。。。