-1

我正在尝试获取用户 ID = 会话 ID 的数字。例如,如果用户 ID = 1,我想获取用户的投注金额。

我尝试使用 MySQL 的 COUNT 但它没有给出正确的结果。我究竟做错了什么?

![][1] http://puu.sh/3KYVf.png

<?php
include_once('db.php');
session_start();

    $selectTotalBets = $db->prepare("SELECT COUNT(*) FROM `users` WHERE `uid` = :uid");

        $selectTotalBets->execute(array(':uid' => $_SESSION['uid']));

            $TotalBetsRow = $selectTotalBets->fetch();

                $userTotalBets = $TotalBetsRow['uid'];



?>
4

2 回答 2

0

include_once('db.php'); session_start();

$selectTotalBets = $db->prepare("SELECT MAX(bid) AS `totalBets` FROM `users` WHERE `uid` = :uid");

    $selectTotalBets->execute(array(':uid' => $_SESSION['uid']));

        $TotalBetsRow = $selectTotalBets->fetch();

            $userTotalBets = $TotalBetsRow['totalBets'];

用户 Max() 用于获取最大值。

于 2013-07-25T04:55:27.350 回答
-1

正如劳伦斯所建议的 -

<?php
include_once('db.php');
session_start();

    $selectTotalBets = $db->prepare("SELECT COUNT(*) AS `totalBets` FROM `users` WHERE `uid` = :uid");

        $selectTotalBets->execute(array(':uid' => $_SESSION['uid']));

            $TotalBetsRow = $selectTotalBets->fetch();

                $userTotalBets = $TotalBetsRow['totalBets'];

?>
于 2013-07-25T00:10:05.390 回答