Announcements | Last Post | |
---|---|---|
SoC Curricula | 09/30/2017 01:08PM | |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM | |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM | |
Unisa contact information | 07/28/2011 01:28PM |
Team_Selection Page May 08, 2013 01:42PM |
Registered: 12 years ago Posts: 22 Rating: 0 |
I just seem to be going around in circles. I would really appreciate any advice or guidance as to how I can go about completing the Selections Page. Thank you.Language: PHP<input type = "checkbox" name = "players" value = "<?php $player_id ?>;">
Re: Team_Selection Page May 08, 2013 03:08PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: Team_Selection Page May 08, 2013 04:25PM |
Registered: 12 years ago Posts: 22 Rating: 0 |
Re: Team_Selection Page May 08, 2013 11:18PM |
Registered: 12 years ago Posts: 22 Rating: 0 |
Re: Team_Selection Page May 13, 2013 09:03AM |
Registered: 12 years ago Posts: 22 Rating: 0 |
With the code above, I am able to post the values to a page called select.php where the player_id's and fixture_id selected is displayed in a table. My problem is that I do not know how to extract the values of the array to then use in my SQL statement. I use the following code to display the player_id's in the table in select.php when the coach presses the Submit button.Language: PHPecho "<tr><td>$fname</td><td>$sname</td><td><input type = ';checkbox'; name = ';players[]'; value = $player_id</td></tr>"; echo "<tr><td>$opponents</td><td>$date</td><td>$venue</td><td><input type = ';radio'; name = ';fixtures[]'; value = $fixture_id</td></tr>";
Language: PHP$players = $_POST[';players';]; $n = count ($players); for ($i = 0; $i < $n; $i++) { echo "<tr><td>$players[$i]</td></tr><br>";
Re: Team_Selection Page May 13, 2013 09:26AM |
Registered: 11 years ago Posts: 106 Rating: 0 |
Re: Team_Selection Page May 13, 2013 09:43AM |
Registered: 12 years ago Posts: 22 Rating: 0 |
Re: Team_Selection Page May 13, 2013 10:03AM |
Registered: 11 years ago Posts: 106 Rating: 0 |
Re: Team_Selection Page May 13, 2013 10:34AM |
Registered: 12 years ago Posts: 22 Rating: 0 |
My problem is that when I use $player[$i] outside the table, I can only access the last player checked. So my SQL statement does not update each position in selection_table, BATSMAN, BOWLER, ALLROUNDER, WICKETKEEPER, etc even though I am able to display in a table prior to running the UPDATE statement, the player_id's for each of these positions.:Language: PHPLanguage: PHP$players = $_POST[';players';]; $n = count ($players); for ($i = 0; $i < $n; $i++) { echo "<tr><td>$players[$i]</td></tr><br>";
Language: PHPquery = "UPDATE selection_table SET batsman1 = ';$players[$i]';, batsman2 = ';$players[$i]';,...WHERE fixture_id = ';$fixtures';";
Re: Team_Selection Page May 13, 2013 10:54AM |
Registered: 11 years ago Posts: 106 Rating: 0 |
Re: Team_Selection Page May 13, 2013 12:17PM |
Registered: 12 years ago Posts: 22 Rating: 0 |
once the loop has ended and I am not sure if I tried assigning each iteration of the loop to a variable and then using those variables in my SQL statement like so:Language: PHP$players[$i]
Language: PHP$players = $_POST[';players';]; $n = count ($players); for ($i = 0; $i < $n; $i++) { $bat1 = $players[$i]; $bat2 = $players[$i]; //etc...... } //SQL statement... query = "UPDATE selection_table SET batsman1 = ';$bat1';, batsman2 = ';$bat2';,...WHERE fixture_id = ';$fixtures';";
Re: Team_Selection Page May 13, 2013 02:18PM |
Registered: 11 years ago Posts: 106 Rating: 0 |
Language: PHPfor ($i = 0; $i < $n; $i++) { $bat1 = $players[$i]; $bat2 = $players[$i]; //etc...... }
Language: PHP$bat1 = $players[10]; $bat2 = $players[10]; ........ $bat10 = $players[10]; $bat11 = $players[10];
Language: PHPquery = "UPDATE selection_table SET batsman1 = ';$players[0]';, batsman2 = ';$players[1]';,...WHERE fixture_id = ';$fixtures';";
Re: Team_Selection Page May 13, 2013 03:00PM |
Registered: 12 years ago Posts: 22 Rating: 0 |
and then use them in the SQL statement as you have suggested.Language: PHP$players = $_POST[';players';];
Re: Team_Selection Page May 13, 2013 08:33PM |
Registered: 12 years ago Posts: 22 Rating: 0 |
Re: Team_Selection Page May 13, 2013 09:21PM |
Registered: 11 years ago Posts: 106 Rating: 0 |
Re: Team_Selection Page May 13, 2013 10:09PM |
Registered: 12 years ago Posts: 22 Rating: 0 |
Re: Team_Selection Page May 19, 2013 01:01PM |
Registered: 11 years ago Posts: 10 Rating: 0 |
Re: Team_Selection Page May 24, 2013 12:46PM |
Registered: 11 years ago Posts: 106 Rating: 0 |