尝试创建一个页面,用户可以使用基础,一个标记和眼睛颜色创建一个角色。这三个描述都存储在单独的表中,并随机调用。我想限制它们被调用的次数,这样用户在找到他们喜欢的组合之前就无法完成所有操作。
<?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来说还是真的很新,所以如果这是一个简单的错误我会道歉。