如何输出php中“as variable”函数设置的mysql变量?
function ClassBalance()
{
global $con_char;
$data = $con_char->prepare('SELECT
(SELECT class FROM characters WHERE class = 1) AS warrior,
(SELECT class FROM characters WHERE class = 2) AS paladin,
(SELECT class FROM characters WHERE class = 3) AS hunter,
(SELECT class FROM characters WHERE class = 4) AS rogue,
(SELECT class FROM characters WHERE class = 5) AS priest,
(SELECT class FROM characters WHERE class = 7) AS shaman,
(SELECT class FROM characters WHERE class = 8) AS mage,
(SELECT class FROM characters WHERE class = 9) AS warlock,
(SELECT class FROM characters WHERE class = 11) AS druid');
$data->execute();
while($result = $data->fetchAll(PDO::FETCH_ASSOC))
{
foreach($result as $row)
{
echo $row['warrior'];
}
}
}
ClassBalance();
我不能让它以任何方式工作,它既不输出任何错误,所以我不知道如何继续这个。
感谢在这个问题上我能得到的所有帮助。
1条答案
按热度按时间5q4ezhmt1#
[测试此代码][1]