从MYSQL偶然选择元素

时间:2018-07-18 14:53:16

标签: php

您好,我试图制作一个脚本,在脚本中从表中选择随机列,但要基于机会。我的桌子看起来有点:

ID | NAME | CHANCE
1   Test     20
2   Test     50

//For now i am generating random column like that:

$item = $odb -> prepare("SELECT * FROM `roulette_items` ORDER BY RAND() LIMIT 1");
$item -> execute();
$getInfo = $item -> fetch(PDO::FETCH_ASSOC);

//But how do i involve chances to this?
//Should i first?
"SELECT `CHANCE` from `roulette_items`"
//and then the math?

0 个答案:

没有答案