I'm trying to figure out a simpler way to code a PHP script so that the $_POST array can be easily dissected. Soo .. I have 10 input="text" fields in a form:
<form action="scores2.php" method="POST">
<table>
<tr>
<td>Player 1 Name: </td>
<td><input type="text" name="name1" /></td>
<td>Score:</td>
<td><input type="text" name="score1" size="3" maxlength="3" /></td></tr>
<!_--------------------_>
NOW I Want to have each "name" and "score" connected to its respective player so that when I output:
<?php foreach($_POST as "name" => "score") {
echo "name - score <br />";
}
?>
It will output the name of the player with their score. also I'm trying to calculate the average of the scores (5 players) and any score above average be shown in green and below in red. then I can use the arsort() function to sort in descending order... any help much appreciated
<input type="text" name="playerinfo[1][name]" />
<input type="text" name="playerinfo[1][score]" size="3" maxlength="3" />
<input type="text" name="playerinfo[2][name]" />
<input type="text" name="playerinfo[2][score]" size="3" maxlength="3" />
<input type="text" name="playerinfo[3][name]" />
<input type="text" name="playerinfo[3][score]" size="3" maxlength="3" />
//Something like this your saying for a name and one score relation in a multi-dimentional array? I like it
<form action="scores2.php" method="POST">
<table>
<tr>
<td>Player 1 Name: </td>
<td><input type="text" name="name1" /></td>
<td>Score:</td>
<td><input type="text" name="score1" size="3" maxlength="3" /></td></tr>
<!_--------------------_>
NOW I Want to have each "name" and "score" connected to its respective player so that when I output:
<?php foreach($_POST as "name" => "score") {
echo "name - score <br />";
}
?>
It will output the name of the player with their score. also I'm trying to calculate the average of the scores (5 players) and any score above average be shown in green and below in red. then I can use the arsort() function to sort in descending order... any help much appreciated
<input type="text" name="playerinfo[1][name]" />
<input type="text" name="playerinfo[1][score]" size="3" maxlength="3" />
<input type="text" name="playerinfo[2][name]" />
<input type="text" name="playerinfo[2][score]" size="3" maxlength="3" />
<input type="text" name="playerinfo[3][name]" />
<input type="text" name="playerinfo[3][score]" size="3" maxlength="3" />
//Something like this your saying for a name and one score relation in a multi-dimentional array? I like it