【发布时间】:2014-08-16 08:50:10
【问题描述】:
我正在尝试从 url "/view.php?postID=2" 获取 id,代码如下:
$post = "SELECT * FROM news WHERE postID='$postID'";
$post1 = mysql_query($post);
$postV = mysql_fetch_array($post1);
$postID = $postV['postID'];
$postImg = $postV['img'];
$postTitle = $postV['title'];
$postAuthor = $postV['author'];
$postDate = $postV['date'];
$postCategory = $postV['category'];
$postText = $postV['text'];
<?php
if (isset($_GET['postID'])) {
$newsID = $_GET['postID'];
}
echo "<section class='view_news'>
<img class='view_newsimg' src='$postImg'>
<h3 class='lath'>$postTitle</h3>
<ul class='det'>
<li class='adc'>avtori: $postAuthor</li>
<li class='adc'>TariRi: $postDate</li>
<li class='adc'>kategoria: $postCategory</li>
</ul>
<p class='news'>
$postText
</p>
</section>";
?>
但它只显示 postID = 1 的数组中的数据
谁能告诉我该怎么做?谢谢:)
【问题讨论】:
-
@mano 这不是他的问题。 URL 包含
?postID=2,但他的查询返回postID = 1。 -
在执行查询之前你在哪里设置
$postID?