Nieuw lid |
|
Hey,
Ik ben bezig met een pagina te maken waar ik verschillende spelers uit een database haal en waar ik een score bij kan invullen en nu wil ik dat hij bij elke speler de juiste score zet nu doet hij het niet.
ik werk met array's
de code
<?php
mysql_connect ("localhost","*******","********");
mysql_select_db("********");
$ploeg = "De Kleppers" ;
$x = 1 ;
$query = "SELECT * FROM `spelers` WHERE `ploeg` = '$ploeg' ORDER BY totaal ASC ";
$sql = mysql_query($query) or die (mysql_error());
$num = mysql_num_rows($sql);
if ($_POST['Submit']) {
for($i=0;$i<$num;$i++) {
echo '<pre>';
print_r( $nr[$i] );
echo '</pre>';
$query = "UPDATE spelers SET nr1='$nr[$i]' WHERE naam = '$naam'";
mysql_query($query) or die (mysql_error());
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<div align="center">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="2%" bgcolor="#3399FF"><strong>Pl.</strong></td>
<td width="15%" bgcolor="#3399FF"><strong>Naam</strong></td>
<td width="15%" bgcolor="#3399FF"><strong>Ploeg</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>1</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>2</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>3</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>4</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>5</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>6</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>7</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>8</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>9</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>10</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>11</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>12</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>13</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>14</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>15</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>16</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>17</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>18</strong></td>
<td width="2%" bgcolor="#3399FF"><strong>T</strong></td>
</tr>
<?php
if ($num == 0) {
echo "Er zijn geen spelers aan deze ploeg toegevoegd" ;
}
while($obj= mysql_fetch_object($sql)){
?>
<tr>
<td bgcolor="#33CCFF"><?php echo "$x" ; $x=$x+1; ?></td>
<td bgcolor="#33CCFF"><?php echo "$obj->naam"; ?><input name="naam" type="hidden" value="<?php echo "$obj->naam"; ?>" /></td>
<td bgcolor="#33CCFF"><?php echo "$obj->ploeg" ; ?></td>
<td><input value="<?php echo "$obj->nr1"; ?>" name="nr1[]" type="text" id="1" size="2" /></td>
<td><input value="<?php echo "$obj->nr2" ; ?>" name="nr[]" type="text" id="2" size="2" /></td>
<td><input value="<?php echo "$obj->nr3" ; ?>" name="nr[]" type="text" id="3" size="2" /></td>
<td><input value="<?php echo "$obj->nr4" ; ?>" name="nr[]" type="text" id="4" size="2" /></td>
<td><input value="<?php echo "$obj->nr5" ; ?>" name="nr[]" type="text" id="5" size="2" /></td>
<td><input value="<?php echo "$obj->nr6" ; ?>" name="nr[]" type="text" id="6" size="2" /></td>
<td><input value="<?php echo "$obj->nr7" ; ?>" name="nr[]" type="text" id="7" size="2" /></td>
<td><input value="<?php echo "$obj->nr8" ; ?>" name="nr[]" type="text" id="8" size="2" /></td>
<td><input value="<?php echo "$obj->nr9" ; ?>" name="nr[]" type="text" id="9" size="2" /></td>
<td><input value="<?php echo "$obj->nr10" ; ?>" name="nr[]" type="text" id="10" size="2" /></td>
<td><input value="<?php echo "$obj->nr11" ; ?>" name="nr[]" type="text" id="11" size="2" /></td>
<td><input value="<?php echo "$obj->nr12" ; ?>" name="nr[]" type="text" id="12" size="2" /></td>
<td><input value="<?php echo "$obj->nr13" ; ?>" name="nr[]" type="text" id="13" size="2" /></td>
<td><input value="<?php echo "$obj->nr14" ; ?>" name="nr[]" type="text" id="14" size="2" /></td>
<td><input value="<?php echo "$obj->nr15" ; ?>" name="nr[]" type="text" id="15" size="2" /></td>
<td><input value="<?php echo "$obj->nr16" ; ?>" name="nr[]" type="text" id="16" size="2" /></td>
<td><input value="<?php echo "$obj->nr17" ; ?>" name="nr[]" type="text" id="17" size="2" /></td>
<td><input value="<?php echo "$obj->nr18" ; ?>" name="nr[]" type="text" id="18" size="2" /></td>
<td bgcolor="#33CCFF"><?php echo "$obj->totaal" ; ?></td>
</tr>
<tr>
<?php } ?>
<td colspan="23">
<input type="submit" name="Submit" value="Score toevoegen" />
</td>
</tr>
</table>
</div>
</form>
<?php $ploeg = "De Kleppers" ; $x = 1 ; $query = "SELECT * FROM `spelers` WHERE `ploeg` = '$ploeg' ORDER BY totaal ASC "; if ($_POST['Submit']) { for($i=0;$i<$num;$i++) { $query = "UPDATE spelers SET nr1='$nr[$i]' WHERE naam = '$naam'"; } } ?> <form action="" method="post" enctype="multipart/form-data"> <div align="center"> <table border="0" cellspacing="1" cellpadding="1"> <tr> <td width="2%" bgcolor="#3399FF"><strong>Pl.</strong></td> <td width="15%" bgcolor="#3399FF"><strong>Naam</strong></td> <td width="15%" bgcolor="#3399FF"><strong>Ploeg</strong></td> <td width="2%" bgcolor="#3399FF"><strong>1</strong></td> <td width="2%" bgcolor="#3399FF"><strong>2</strong></td> <td width="2%" bgcolor="#3399FF"><strong>3</strong></td> <td width="2%" bgcolor="#3399FF"><strong>4</strong></td> <td width="2%" bgcolor="#3399FF"><strong>5</strong></td> <td width="2%" bgcolor="#3399FF"><strong>6</strong></td> <td width="2%" bgcolor="#3399FF"><strong>7</strong></td> <td width="2%" bgcolor="#3399FF"><strong>8</strong></td> <td width="2%" bgcolor="#3399FF"><strong>9</strong></td> <td width="2%" bgcolor="#3399FF"><strong>10</strong></td> <td width="2%" bgcolor="#3399FF"><strong>11</strong></td> <td width="2%" bgcolor="#3399FF"><strong>12</strong></td> <td width="2%" bgcolor="#3399FF"><strong>13</strong></td> <td width="2%" bgcolor="#3399FF"><strong>14</strong></td> <td width="2%" bgcolor="#3399FF"><strong>15</strong></td> <td width="2%" bgcolor="#3399FF"><strong>16</strong></td> <td width="2%" bgcolor="#3399FF"><strong>17</strong></td> <td width="2%" bgcolor="#3399FF"><strong>18</strong></td> <td width="2%" bgcolor="#3399FF"><strong>T</strong></td> </tr> <?php if ($num == 0) { echo "Er zijn geen spelers aan deze ploeg toegevoegd" ; } ?> <tr> <td bgcolor="#33CCFF"> <?php echo "$x" ; $x=$x+1; ?></td> <td bgcolor="#33CCFF"> <?php echo "$obj->naam"; ?><input name="naam" type="hidden" value=" <?php echo "$obj->naam"; ?>" /></td> <td bgcolor="#33CCFF"> <?php echo "$obj->ploeg" ; ?></td> <td><input value=" <?php echo "$obj->nr1"; ?>" name="nr1[]" type="text" id="1" size="2" /></td> <td><input value=" <?php echo "$obj->nr2" ; ?>" name="nr[]" type="text" id="2" size="2" /></td> <td><input value=" <?php echo "$obj->nr3" ; ?>" name="nr[]" type="text" id="3" size="2" /></td> <td><input value=" <?php echo "$obj->nr4" ; ?>" name="nr[]" type="text" id="4" size="2" /></td> <td><input value=" <?php echo "$obj->nr5" ; ?>" name="nr[]" type="text" id="5" size="2" /></td> <td><input value=" <?php echo "$obj->nr6" ; ?>" name="nr[]" type="text" id="6" size="2" /></td> <td><input value=" <?php echo "$obj->nr7" ; ?>" name="nr[]" type="text" id="7" size="2" /></td> <td><input value=" <?php echo "$obj->nr8" ; ?>" name="nr[]" type="text" id="8" size="2" /></td> <td><input value=" <?php echo "$obj->nr9" ; ?>" name="nr[]" type="text" id="9" size="2" /></td> <td><input value=" <?php echo "$obj->nr10" ; ?>" name="nr[]" type="text" id="10" size="2" /></td> <td><input value=" <?php echo "$obj->nr11" ; ?>" name="nr[]" type="text" id="11" size="2" /></td> <td><input value=" <?php echo "$obj->nr12" ; ?>" name="nr[]" type="text" id="12" size="2" /></td> <td><input value=" <?php echo "$obj->nr13" ; ?>" name="nr[]" type="text" id="13" size="2" /></td> <td><input value=" <?php echo "$obj->nr14" ; ?>" name="nr[]" type="text" id="14" size="2" /></td> <td><input value=" <?php echo "$obj->nr15" ; ?>" name="nr[]" type="text" id="15" size="2" /></td> <td><input value=" <?php echo "$obj->nr16" ; ?>" name="nr[]" type="text" id="16" size="2" /></td> <td><input value=" <?php echo "$obj->nr17" ; ?>" name="nr[]" type="text" id="17" size="2" /></td> <td><input value=" <?php echo "$obj->nr18" ; ?>" name="nr[]" type="text" id="18" size="2" /></td> <td bgcolor="#33CCFF"> <?php echo "$obj->totaal" ; ?></td> </tr> <tr> <?php } ?> <td colspan="23"> <input type="submit" name="Submit" value="Score toevoegen" /> </td> </tr> </table> </div> </form>
|