Hello,
On my way down a long road to develop a web form for a local sports league.
Upon form submission, on my process.php page, I am trying to tally up each of the player's highlights throughout the match form.
Right now I have code which works, but I am only comparing the first HOME id field to the 31 other fields (32 fields of player/id and highlightsplayerH1, highlightsplayerH2, highlightsplayerH3 etc..)
I still have VISITORS to do also with a similar naming convention highlightsplayerV1, highlightsplayerV2 etc..
Here is my code so far: I know there is an easier way to step through these...
$ph1 = '';
if (isset($highlightsplayerH1)) {
$ph1 = $playerH1." - ".$highlightsplayerH1;
} else {}
if ($playerH1 == $playerH11 && isset($highlightsplayerH11)) {
$ph1 = $ph1.", ".$highlightsplayerH11;
} else {}
if ($playerH1 == $playerH12 && isset($highlightsplayerH12)) {
$ph1 = $ph1.", ".$highlightsplayerH12;
} else {}
if ($playerH1 == $playerH13 && isset($highlightsplayerH13)) {
$ph1 = $ph1.", ".$highlightsplayerH13;
} else {}
if ($playerH1 == $playerH14 && isset($highlightsplayerH14)) {
$ph1 = $ph1.", ".$highlightsplayerH14;
} else {}
if ($playerH1 == $playerH15 && isset($highlightsplayerH15)) {
$ph1 = $ph1.", ".$highlightsplayerH15;
} else {}
if ($playerH1 == $playerH16 && isset($highlightsplayerH16)) {
$ph1 = $ph1.", ".$highlightsplayerH16;
} else {}
if ($playerH1 == $playerH17 && isset($highlightsplayerH17)) {
$ph1 = $ph1.", ".$highlightsplayerH17;
} else {}
if ($playerH1 == $playerH18 && isset($highlightsplayerH18)) {
$ph1 = $ph1.", ".$highlightsplayerH18;
} else {}
if ($playerH1 == $playerH19 && isset($highlightsplayerH19)) {
$ph1 = $ph1.", ".$highlightsplayerH19;
} else {}
if ($playerH1 == $playerH20 && isset($highlightsplayerH20)) {
$ph1 = $ph1.", ".$highlightsplayerH20;
} else {}
if ($playerH1 == $playerH21 && isset($highlightsplayerH21)) {
$ph1 = $ph1.", ".$highlightsplayerH21;
} else {}
if ($playerH1 == $playerH22 && isset($highlightsplayerH22)) {
$ph1 = $ph1.", ".$highlightsplayerH22;
} else {}
if ($playerH1 == $playerH23 && isset($highlightsplayerH23)) {
$ph1 = $ph1.", ".$highlightsplayerH23;
} else {}
if ($playerH1 == $playerH24 && isset($highlightsplayerH24)) {
$ph1 = $ph1.", ".$highlightsplayerH24;
} else {}
if ($playerH1 == $playerH25 && isset($highlightsplayerH25)) {
$ph1 = $ph1.", ".$highlightsplayerH25;
} else {}
if ($playerH1 == $playerH26 && isset($highlightsplayerH26)) {
$ph1 = $ph1.", ".$highlightsplayerH26;
} else {}
if ($playerH1 == $playerH27 && isset($highlightsplayerH27)) {
$ph1 = $ph1.", ".$highlightsplayerH27;
} else {}
if ($playerH1 == $playerH28 && isset($highlightsplayerH28)) {
$ph1 = $ph1.", ".$highlightsplayerH28;
} else {}
if ($playerH1 == $playerH29 && isset($highlightsplayerH29)) {
$ph1 = $ph1.", ".$highlightsplayerH29;
} else {}
if ($playerH1 == $playerH30 && isset($highlightsplayerH30)) {
$ph1 = $ph1.", ".$highlightsplayerH30;
} else {}
if ($playerH1 == $playerH31 && isset($highlightsplayerH31)) {
$ph1 = $ph1.", ".$highlightsplayerH31;
} else {}
if ($playerH1 == $playerH32 && isset($highlightsplayerH32)) {
$ph1 = $ph1.", ".$highlightsplayerH32;
} else {}
$ph1Array = explode(",",$ph1);
$ph1Count = count($ph1Array);
echo "Itemized Highlights<br />";
echo $ph1." Wow, you shot ".$ph1Count." highlights!<br />";
Here the output in Firefox...
The variable $playerH1 or V1 (up to 32) all contain the players ID.
So I would like to compare and list (once) the ID and all the highlights associated with that ID.
I was working on some sort of loop code to handle this but I must admit I am not an expert.
$i = 0;
/* phht = Player Home Highlight Total */
$phht = '';
while ($i<=32){
$i++;
if ($playerH1 == ($playerH.$i)) {
$phht = $playerhighlightsH.$i;
echo $phht;
echo "<br />";
} else {
echo $phht." "."There were no highlights for the Home team this week.<br>";
}
}