任何人都可以在這裏發現任何錯誤?對不起再次提問,但我是新來的,不太確定發佈時該怎麼做。挑選中獎券時陣列錯誤。
$stmt = $db->prepare('INSERT INTO `giveawayusers` (`giveawayid`, `steamid64`, `coins`, `from`, `to`) VALUES (:id, :id64, :coins, :from, :to)');
$stmt->execute(array(
":id" => $id,
":id64" => $steamUserId,
":coins" => $coins,
":from" => $currentCoins,
":to" => $totalCoins,
));
if($currentCoins+$coins>=$totalCoins)
{
$winningticket = mt_rand(1,$totalCoins);
$stmt = $db->prepare('SELECT `steamid64` FROM `giveawayusers` WHERE `from` <= :winningticket AND `to` >= :winningticket AND `giveawayid`=:id');
$stmt->bindValue(':id', $id);
$stmt->bindValue(':winningticket', $winningticket);
$stmt->execute();
$winner = $stmt->fetch();
我認爲錯誤可能是這裏
$stmt = $db->prepare('SELECT `steamid64` FROM `giveawayusers` WHERE `from` <= :winningticket AND `to` >= :winningticket AND `giveawayid`=:id');
我的數據庫結構是這樣的:
https://gyazo.com/4ec4874d879b2cf4bd1d2450e57cfa71 https://gyazo.com/95cddb0a1c7b8fd1c360a6d5a1b2e129
乾杯, 詹姆斯
你有什麼錯誤之處?我不確定這裏有什麼問題。 – TopCheese
未選中勝者。看看skin-room.com,你就會明白 –
所以你從查詢中得到一個空的結果? – TopCheese