你好,我是 php 新手,但我不能让这个动态列表在这里工作是代码..
<?php
if (isset($_GET['id'])) {
include "DocumentSystem/scripts/connect_to_mysql.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
$dynamicList = "";
$sql = mysql_query("SELECT * FROM documents WHERE id='$id' LIMIT 1");
$documentCount = mysql_num_rows($sql); // count the output amount
if ($documentCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$document_name = $row["document_name"];
$full_document = $row["full_document"];
$dynamicList .= '<div id="slidepic">
<img src="images/document_images/'.$id.'.jpg" width="550" height="350" />
<div id="slideshow">
<h1> <a href="document.php?id='.$id.'">'.$document_name.'</a></h1>
<br />
<p1><a href="document.php?id='.$id.'">'.$full_document.'</a></p1>
</div>
</div>';
}
} else {
$dynamicList = "We have no documents listed in the database";
}
mysql_close();
?>
它正在从 url 获取正确的 id,但查询对我不起作用,谢谢任何答案!