gpt4 book ai didi

php - 添加两个 mysql 列并返回总计时遇到问题

转载 作者:行者123 更新时间:2023-11-29 12:26:54 24 4
gpt4 key购买 nike

我正在尝试添加 mysql 列,然后将列总数返回到 php 页面。我的代码可以工作,但它没有返回值:

<?
$pointresults2 = $dbh->prepare("SELECT sum(features + contributions + likes
)
AS total FROM points WHERE (ID = :user_ID)");
$pointresults->bindParam(':user_ID', $user_ID, PDO::PARAM_INT);
$pointresults2->execute();
$pointrow2 = $pointresults2->fetchAll(PDO::FETCH_ASSOC);
?>

<h3><b>Points TEST: <?php echo $pointrow2[0]['total'] ?></b></h3>

最佳答案

您的情况没有功能贡献点赞。此外,您还提供了错误的名称作为参数user_ID

<?php
$stmt = $dbh->prepare("SELECT sum(features + contributions + likes) AS total FROM points WHERE (ID = :user_ID)");
$stmt->bindParam(':user_ID', $user_ID, PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);

echo '<h3>'. $user_ID .' have '. $row['total'] .' Points.</h3>';
?>

关于php - 添加两个 mysql 列并返回总计时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28182965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com