我想添加多个分数,但是如果我这样做的话,第二个填写表单就不起作用了。第一次填写表格运作良好。我知道这不是一个很好的代码,我怎么能用一种代码类型呢?
希望你能提供帮助。
这是我的代码:
<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']."') ");
}
?>
答案 0 :(得分:0)
你在那里有一些奇怪的逻辑,你基本上说的是:
$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}
我不确定你想要实现的目标,但我会考虑修改