【问题标题】:Only show items when person_id is correct?仅在 person_id 正确时显示项目?
【发布时间】:2016-06-24 10:06:22
【问题描述】:

我目前正在尝试编写一段代码,我想在我的页面中显示数据库的 2 个单元格,但前提是 person_id 正确。

我以前使用过占位符,但似乎无法在 OOP 中找到这样做的方法?

$connect = new MySQL('localhost','username','password');
$connect->Database('dbname');
$posts = $connect->Fetch('group_table WHERE person_id = :user');
$posts->execute[('user' => $_SESSION['id'])];

if ($posts && mysql_num_rows($posts) > 0) {
 echo "Here is some post data:<BR>";

 while ($record = mysql_fetch_array($posts)) {
  ?>

<div class="row">
<div class="col-lg-6 white">
    <?php echo $record['groupname'];?>
        <?php echo $record['group_omschrijving'];?>
    </div>
</div>

【问题讨论】:

    标签: php database oop session


    【解决方案1】:

    我已经通过声明 for $person 的变量来修复它

    $posts = $connect->Fetch('group_table WHERE person_id = "$person_id"');
    $person_id = $_SESSION['id'];
    

    【讨论】:

      猜你喜欢
      • 2021-12-08
      • 2016-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-17
      • 2011-08-27
      • 1970-01-01
      相关资源
      最近更新 更多