我网站的用户可以订阅他们的一些动物参加比赛。我的代码运行良好,但存在一个大问题。当用户按下订阅时,页面会重新加载,但由于 isset 在按钮本身的回声之后,因此需要在按钮文本更改为“已订阅”之前刷新页面。如您所见,更改顺序会产生问题。谁能帮帮我?我自己没有选择。(我翻译了变量等)
<form action="" method="post" name="frmSubscribe">
<?php
$Counter = 0;
$sql = "Select * from Animals where username='".$_SESSION['User']."' ";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result)){
echo $row['Animalname'];
$Duiven[] = $row['AnimalID'];
$Username[] = $row['username'];
?>
<input type='submit' <?php echo "name= ".$Buttons[$Counter].""; ?> value='<?php
$sqlSubscribed = "SELECT * FROM Competitionresults WHERE AnimalID='".$Animals[$Counter]."'";
$resultSubscribed = mysql_query($sqlSubscribed);
if(mysql_num_rows($resultSubscribed) == 0){ echo "Subscribe";}
else {echo "deregister";}
?>'><br/><?php
$Teller++;
}
if (isset($_POST['btnSubscribe1'])){
$sqlCheck = "SELECT * FROM Competitionresults WHERE AnimalID='".$Animals[0]."'";
$resultCheck = mysql_query($sqlCheck);
if (mysql_num_rows($resultCheck) == 0){
$sql1 = "INSERT INTO Competitionresuls (AnimalID, username) VALUES ('".$Animals[0]."','".$Username[0]."')";
$result1 = mysql_query($sql1);
$row=mysql_fetch_array($result1);
?><?php
}
}
......等下一个动物。