gpt4 book ai didi

php - PHP MYSQL 如何添加多个评分结果

转载 作者:行者123 更新时间:2023-11-30 00:34:09 24 4
gpt4 key购买 nike

我想添加多个分数,但如果我这样做,第二个填写的表格将不起作用。第一份填写的表格效果很好。我知道这不是一个好的代码,我怎样才能用一种代码类型来做到这一点?

希望能帮到你。

这是我的代码:

<form action="e2admin.php" method="post">
<div class="input-group">
<input style="width:410px;" type="text" class="form-control" name="date" placeholder="Datum" /><br>
<select name="thuisteam1">
<option value=""></option>
<?php
mysql_data_seek($result, 0);

if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['Team'] . '">' . $row['Team'] . '</option>';
}
}
?>

</select>
<input style="width:20px; text-align:center;" type="text" class="form-control" name="scorethuis1" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" class="form-control" name="scoreuit1" placeholder="0" />
<select name="uitteam1">
<option value=""></option>
<?php
mysql_data_seek($result, 0);

if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['Team'] . '">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<select name="thuisteam2">
<option value=""></option>
<?php
mysql_data_seek($result, 0);

if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['Team'] . '">' . $row['Team'] . '</option>';
}
}
?>

</select>
<input style="width:20px; text-align:center;" type="text" class="form-control" name="scorethuis2" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" class="form-control" name="scorethuis2" placeholder="0" />
<select name="uitteam2">
<option value=""></option>
<?php
mysql_data_seek($result, 0);

if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['Team'] . '">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<input style="margin-left:330px;" type="submit" class="form-control" value="Toevoegen" />
</div>
</form>
<?php

if( $_POST['scorethuis1'] > $_POST['scoreuit1']) {
//echo $_POST["thuisteam1"];
mysql_query("UPDATE e2teams SET Punten = Punten+3 WHERE Team ='".$_POST['thuisteam1']."'");

}
else if( $_POST['scorethuis1'] > $_POST['scoreuit1']) {
//echo $_POST["thuisteam1"];
mysql_query("UPDATE e2teams SET Punten = Punten+3 WHERE Team ='".$_POST['uitteam1']."'");

}
else if( $_POST['scorethuis1'] == $_POST['scoreuit1']) {
//echo $_POST["thuisteam1"];
mysql_query("UPDATE e2teams SET Punten = Punten+1 WHERE Team in ('".$_POST['thuisteam1']."', '".$_POST['uitteam1']."') ");

}

else if( $_POST['scorethuis2'] > $_POST['scoreuit2']) {
//echo $_POST["thuisteam1"];
mysql_query("UPDATE e2teams SET Punten = Punten+3 WHERE Team ='".$_POST['thuisteam2']."'");

}
else if( $_POST['scorethuis2'] > $_POST['scoreuit2']) {
//echo $_POST["thuisteam1"];
mysql_query("UPDATE e2teams SET Punten = Punten+3 WHERE Team ='".$_POST['uitteam2']."'");

}
else if( $_POST['scorethuis2'] == $_POST['scoreuit2']) {
//echo $_POST["thuisteam1"];
mysql_query("UPDATE e2teams SET Punten = Punten+1 WHERE Team in ('".$_POST['thuisteam2']."', '".$_POST['uitteam2']."') ");

}

?>

最佳答案

这是你那里发生的一些奇怪的逻辑,你基本上说的是:

$foo = 1
if($foo > 1) {//you'll skip this}
else if($foo > 1) {//and this}
else if($foo == 1) {//and get here}

$foo = 2
if($foo > 1) {//you'll get here}
else if($foo > 1) {//skip this}
else if($foo == 1) {//and this}

我不确定您想要实现什么目标,但我会考虑修改

关于php - PHP MYSQL 如何添加多个评分结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22311496/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com