douju1953 2014-09-17 19:15
浏览 59
已采纳

如何在mysql php中从数据库中回显一个未选中的选项值

I want to echo or display an "unselected(2nd) option" from the db.

please help!!!

1st(selected) option where it will display the value "ACCEPTED"

<a type="button" class="btn btn-default btn-round btn-md" href="#">
   <?php echo $row['status'];?>
</a>  

2nd(unselected) option where it will display the value "PENDING"

<a type="button" class="btn btn-default btn-round btn-md" href="#">
   *HOW TO ECHO A VALUE IN HERE FROM THE DB?*
</a>  

PHP CODE(this is mysql query)

$stmt = $db->prepare('SELECT * FROM blog_members WHERE memberID = :memberID') ;
$stmt->execute(array(':memberID' => $_GET['id']));
$row = $stmt->fetch(); 
  • 写回答

1条回答 默认 最新

  • du0173 2014-09-17 20:38
    关注

    I think this is what you are looking for

    if ($row['status'] == "PENDING") {
        echo '<a type="button" class="btn btn-default btn-round btn-md" href="#">
            PENDING
        </a>';
    } else {
        echo '<a type="button" class="btn btn-default btn-round btn-md" href="#">
            ACCEPTED
        </a>';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?