我只是想从名为“类别”的表中检索条目。
<?php
$conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
$sql = "SELECT description FROM categories WHERE STRCMP(id,:id)=0";
$st = $conn->prepare($sql);
$st->bindValue(":id", $results['article']->category, PDO::PARAM_STR);
$st->execute();
$desc = $st->fetch();
$conn = null;
if ($desc)
{?>
<li><a href="index.php?action=viewByCategory&category=<?php echo $results['article']->category?>"><?php echo htmlspecialchars($desc)?></a></li>
<?php}?>
最佳答案
谢谢大家的解答,终于明白了。你不应该在 php 中像这样关闭括号
<?php? ?>
关于PHP MySQL 简单脚本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47503945/