【发布时间】:2014-04-14 05:23:57
【问题描述】:
我想添加多个分数,但如果我这样做,第二次填写表格将无法正常工作。第一次填写表格运行良好。我知道这不是一个很好的代码,我怎么能用一种代码类型做到这一点?
希望你能帮忙。
这是我的代码:
<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']."') ");
}
?>
【问题讨论】: