有两个按钮,但我不知道为什么我的按钮重复了。
我尝试使用if并且仍然对按钮执行相同的操作。我尝试使用include函数,但仍然没有走到任何地方。这是我的代码:
<?php include"php-MAIN-Info.php";
include"php-MAIN-SignUp+DataBase.php"; $result1 =
mysqli_query($conn, "SELECT * FROM `friends` WHERE user_one =
'".$User_ID."' OR user_two = '".$User_ID."'");
1. List item
if ($result1) { while ($row1 = mysqli_fetch_array($result1)) {
$day = $_SESSION['Info_User_ID']; $longShift = true;
switch (true) {
case ($day == $row1['user_one']):
echo " ";
break;
case ($day == $row1['user_two']):
echo " ";
break;
case ($day == 'Friday' && !$longShift):
echo " ";
break;
default:
?>
<form action="php-SM-Request-Friend+Function.php" id="Button">
<a
type="button"
name="Chat"
id="Chat"
value="Chat">Chat</a>
<ipuut
type="submit"
name="SentRequest"
id="Request">Sent Request</ipuut>
<input type="hidden" name="Friend_ID" value="<?php echo $_SESSION['Info_User_ID']?>">
</form>
<?php
break;
}
} }else{ echo "You Don't Have Any Friends"; }
?>
它正在复制按钮,因为您已经在while
循环中分配了按钮,并且正如while循环中提到的那样,它将继续基于数组中存在的元素数来复制按钮。因此,请尝试按以下方式更改代码排列:跟着
<?php include"php-MAIN-Info.php";
include"php-MAIN-SignUp+DataBase.php"; $result1 =
mysqli_query($conn, "SELECT * FROM `friends` WHERE user_one =
'".$User_ID."' OR user_two = '".$User_ID."'");
1. List item
if ($result1) { while ($row1 = mysqli_fetch_array($result1)) {
$day = $_SESSION['Info_User_ID']; $longShift = true;
switch (true) {
case ($day == $row1['user_one']):
echo " ";
break;
case ($day == $row1['user_two']):
echo " ";
break;
case ($day == 'Friday' && !$longShift):
echo " ";
break;
default:
break;
}
} }else{ echo "You Don't Have Any Friends"; }
?>
<form action="php-SM-Request-Friend+Function.php" id="Button">
<a
type="button"
name="Chat"
id="Chat"
value="Chat">Chat</a>
<input
type="submit"
name="SentRequest"
id="Request">Sent Request</input>
<input type="hidden" name="Friend_ID" value="<?php echo $_SESSION['Info_User_ID']?>">
</form>
是,还可以在表单的输入标签中进行更改,您已将其分配为ipuut
。