我有一个 switch 语句,无论出于何种原因,它都不会更改变量。我默认将其定义为 1,而 $getpage 只会回显为 1,而不是 1,10。我不知道我做错了什么。请有人帮忙。
if (!isset($_SESSION['username'])) {
echo '<meta http-equiv="refresh" content="0; url=memberarea.php">';
}
else {
if (!isset($_GET['sex']) &&
!isset($_GET['age']) &&
!isset($_GET['page'])) {
$_GET['age'] = "x";
$_GET['sex'] = "x";
$_GET['page'] = 1;
$getage = mysqli_real_escape_string($connect, $_GET['age']);
$getsex = mysqli_real_escape_string($connect, $_GET['sex']);
$getpage = mysqli_real_escape_string($connect, $_GET['page']);
}
else {
if ($_GET['age'] != "12-15" ||
$_GET['age'] != "16-18" ||
$_GET['age'] != "19-25" ||
$_GET['age'] != "26-35" ||
$_GET['age'] != "36+") {
$_GET['age'] = "x";
$getage = mysqli_real_escape_string($connect, $_GET['age']);
}
else {
$getage = mysqli_real_escape_string($connect, $_GET['age']);
}
if ($_GET['sex'] != "male" ||
$_GET['sex'] != "female" ||
$_GET['sex'] != "x") {
$_GET['sex'] = "x";
$getsex = mysqli_real_escape_string($connect, $_GET['sex']);
}
else {
$getsex = mysqli_real_escape_string($connect, $_GET['sex']);
}
if (ctype_digit($_GET['page']) === FALSE || $_GET['page'] > 10) {
$_GET['page'] = 1;
$getpage = mysqli_real_escape_string($connect, $_GET['page']);
}
else {
$getpage = mysqli_real_escape_string($connect, $_GET['page']);
}
if ($getsex === "all") {
$getsex = "*";
}
if ($getage === "all") {
$getage = "*";
}
switch($getpage) {
case 1:
$getpage = "1,10";
break;
case 2:
$getpage = "11,20";
break;
case 3:
$getpage = "21,30";
break;
case 4:
$getpage = "31,40";
break;
case 5:
$getpage = "41,50";
break;
case 6:
$getpage = "51,60";
break;
case 7:
$getpage = "61,70";
break;
case 8:
$getpage = "71,80";
break;
case 9:
$getpage = "81,90";
break;
case 10:
$getpage = "91,100";
break;
}
}