尝试创建一个页面,用户可以在其中创建具有基础、一种标记和眼睛颜色的角色。这三个描述都存储在单独的表中,并被随机调用。我想限制它们被调用的次数,以便用户在找到他们喜欢的组合之前无法遍历它们。
<?php
if(!isset($_SESSION['count']))
$_SESSION['count'] = 0;
if($_SESSION['count'] < 5) {
$_SESSION['count']++;
$query = $mysqli->query("SELECT `base` FROM `bases` WHERE `type` = 'Starter' ORDER BY rand()");
while($info = $query->fetch_assoc()) {
$_SESSION['refreshresultbase'] = $info['base'];
}
$querymark = $mysqli->query("SELECT `marking` FROM `markings` WHERE `type` = 'Starter' ORDER BY rand()");
while($infomark = $querymark->fetch_assoc()) {
$_SESSION['refreshresultmarking'] = $infomark['marking'];
}
$query3 = $mysqli->query("SELECT `colour` FROM `eyes` WHERE `type` = 'Starter' ORDER BY rand()");
while($infoeye = $query3->fetch_assoc()) {
$_SESSION['refreshresulteyes'] = $infoeye['colour'];
}
}
?>
对 mysqli 来说仍然很新,所以如果这是一个简单的错误,我深表歉意。