0

我正在尝试从数据库中获取返回的记录。我正在寻找此页面尚未返回的粗体返回问题(返回 = 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 应该是非粗体

4

1 回答 1

0

也许是这样的?

while ($rowq = $prepq->fetch(PDO::FETCH_ASSOC)) {
    $bold = $rowq['returned'] == 1 ? ' font-weight:bold;' : '';
    echo "<li style='margin:30px;{$bold}'>{$rowq['question']}</li>";
}
于 2013-04-06T09:03:39.203 回答