chrisuk Posted September 9, 2008 Share Posted September 9, 2008 I am creating a mini site for a small poker league. Coming on just fine but there is one thing that I am not sure about. Not all players play every week. When I add a game, I have dynamically generated drop downs that I can use which populate with players names from the database. I select this for 1st, 2nd and 3rd positions. However, we keep track of the number of games played by each player, so if i only add these three, the play count will not be updated. So, aswell as dynamic drop downs, I also have a dynamic list of players generated into a table, with their name and a checkbox: <?php $getplayers = "SELECT * from players"; $sql= mysql_query($getplayers) or die(mysql_error()); $row = mysql_fetch_array($sql, MYSQL_ASSOC); extract ($row); while ( $row = @mysql_fetch_array ( $sql ) ){ ?> <table width="551" height="27" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="212" height="27"><span class="style7"><span class="usertext"><? echo $row[player]; ?></span></span></td> <td width="47"><input type="checkbox" name="checkbox" value="checkbox" /></td> <td width="59"><span class="style7"></span></td> </tr> <? } ?> So, not rocket science. What i'm not too sure about is - what logic do I need to use to ensure that the players I select from the checkbox, have their games played count incremented by one? Thanks folks Link to comment https://forums.phpfreaks.com/topic/123436-create-a-list-of-tickboxes-dynamically/ Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2008 Share Posted September 9, 2008 are you looking for the SQL? for each player_id, $sql = "UPDATE player_table SET number_of_games = (number_of_games + 1) WHERE id = '$player_id'"; Link to comment https://forums.phpfreaks.com/topic/123436-create-a-list-of-tickboxes-dynamically/#findComment-637503 Share on other sites More sharing options...
chrisuk Posted September 10, 2008 Author Share Posted September 10, 2008 Hi, Thanks for your reply. that does help for part of the issue, but what I can't quite figure out is: I only want to update one field in the database (the number of games played) for the players that I select via tickbox. So, what code is needed to essentially "for each player selected, play_count = play_count + 1" I use a while loop to generate the tick list, I assume it's some kind of extra loop based on tick boxes selected when the form is submitted?? As it's a dynamic list, I presume using $_post won't work? Unless it creates some kind of array? I may be overly confusing matters! Thanks again Link to comment https://forums.phpfreaks.com/topic/123436-create-a-list-of-tickboxes-dynamically/#findComment-638179 Share on other sites More sharing options...
chrisuk Posted September 11, 2008 Author Share Posted September 11, 2008 bump Link to comment https://forums.phpfreaks.com/topic/123436-create-a-list-of-tickboxes-dynamically/#findComment-638963 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.