我有下面的代码似乎没问题,只是它不会回应结果。如果我将echo语句更改为只读取echo $ pointrow,那么它将返回" array"。所以我按照下面的方式编写了它,现在页面上根本没有任何内容。不确定我做错了什么。点表中确实有一个名为points的列。
<?php
$pointresults = $dbh->prepare("SELECT
wp_users.ID,
points.points
FROM wp_users
LEFT JOIN points on points.ID = wp_users.ID
WHERE (wp_users.ID = $user_ID)");
$pointresults->bindParam(':wp_users.ID', $user_ID, PDO::PARAM_INT);
$pointresults->bindParam(':points.ID', $ID, PDO::PARAM_INT);
$pointresults->execute();
$pointrow = $pointresults->fetchAll(PDO::FETCH_ASSOC);
?>
<?php echo $pointrow[0]['points'] ?>
答案 0 :(得分:1)
请试试这个:
<?php
$pointresults = $dbh->prepare("SELECT
wp_users.ID,
points.points
FROM wp_users
LEFT JOIN points on points.ID = wp_users.ID
WHERE (wp_users.ID = :user_ID)");
$pointresults->bindParam(':user_ID', $user_ID, PDO::PARAM_INT);
$pointresults->execute();
$pointrow = $pointresults->fetchAll();
?>
<?php echo $pointrow[0]['points'] ?>