我有两个文件,一个是显示我网站最新添加的页面,另一个是指向第一页的链接。
问题:如果我包含like
关键字而不是=
,sql
则查询有效。但是,当我使用=
(这是我想要的)时,它返回零行。
代码片段:
头版.php
echo "On " . max($last_date) . ", we had <a href='/latest-txt.php?date=$md'>" . count($last_posts) . "</a> text posts!"
最新的文本.php
$query = $_GET[$md];
$stmt = $db->prepare("SELECT * FROM $db_tb_name WHERE $db_tb_atr_name5 = ? ORDER BY RAND () LIMIT 0, 15");
if($stmt->execute(array("%$query%"))){
echo "Search Results<ol>";
while($data_fetch = $stmt->fetch(PDO::FETCH_ASSOC)){
echo "<li>";
echo "<div class='tagtext'>AUTHOR: ";
echo substr($data_fetch[$db_tb_atr_name2], 0,160)," "," ";
echo "TAG: ";
echo substr($data_fetch[$db_tb_atr_name3], 0,160)," ";
//echo substr($data_fetch[$db_tb_atr_name4], 0,160)," ";
echo "</div>";
echo "<div class='tagtext'>MESSAGE: ";
echo substr($data_fetch[$db_tb_atr_name], 0,160);
echo "</div>";
//echo substr($data_fetch[$db_tb_atr_name], 0,160);
echo "</li><hr/>";
}
}
echo "</ol>";
有人可以帮忙吗?谢谢。