我正在尝试从数据库中获取返回的记录。我正在寻找未返回此页面的粗体返回问题(返回= 1)和非粗体问题(返回= 0)http://starsQA.com/Qbank
这是到目前为止的查询代码:
<?php
include("db_conn.php");
$qry_string = "select * from stars order by starName ASC";
$prep = $pdo_conn->prepare($qry_string);
$prep->execute();
while ($row = $prep->fetch(PDO::FETCH_ASSOC)) {
echo "<button class='tosearch spcbtn' id='tglbtn{$row['starID']}'>{$row['starName']}</button>";
echo "<div style='clear:both;'></div>";
echo "<div style='color:black;' class='tgldiv' id='tgldiv{$row['starID']}'><b>{$row['starName']}</b><br><ol>";
$qry_stringq = "select * from questions where starID = ? && approved = 1";
$prepq = $pdo_conn->prepare($qry_stringq);
$prepq->execute(array($row['starID']));
while ($rowq = $prepq->fetch(PDO::FETCH_ASSOC)) {
echo "<li style='margin:30px'>{$rowq['question']}</li>";
}
echo "<ol'></div>";
echo "<div style='clear:both;'></div>";
}
?>
如果您在搜索框中输入 geno segers 并打开他的按钮,则问题1-26应为粗体,问题27应为非粗体
答案 0 :(得分:0)
也许是这样的?
while ($rowq = $prepq->fetch(PDO::FETCH_ASSOC)) {
$bold = $rowq['returned'] == 1 ? ' font-weight:bold;' : '';
echo "<li style='margin:30px;{$bold}'>{$rowq['question']}</li>";
}