rbragg Posted May 3, 2007 Share Posted May 3, 2007 Hopefully, this will be a quick and painless answer. The values for the the last playerID in the db table are the only values passed in the POST array. I would like to have values for all 17 playerIDs passed and not just the 17th. Thanks in advance. <?php $queryPlayers = " SELECT playerID, player FROM players $playerResults = mysql_query($queryPlayers) or die('Find players query failed: ' . mysql_error()); while ($player = mysql_fetch_array($playerResults)) { echo "<input name='playerID' type='hidden' value='" . $player['playerID'] . "'"; echo "<tr>"; ?> <td align='center'><input name="hits" type="text" size="3" maxlength="3" value="0" class="style3" /></td> <td align='center'><input name="ab" type="text" size="3" maxlength="3" value="0" class="style3" /></td> <td align='center'><input name="bb" type="text" size="3" maxlength="3" value="0" class="style3" /></td> <td align='center'><input name="2b" type="text" size="3" maxlength="3" value="0" class="style3" /></td> <td align='center'><input name="3b" type="text" size="3" maxlength="3" value="0" class="style3" /></td> <td align='center'><input name="hr" type="text" size="3" maxlength="3" value="0" class="style3" /></td> <td align='center'><input name="rbi" type="text" size="3" maxlength="3" value="0" class="style3" /></td> </tr> <?php } ?> Quote Link to comment Share on other sites More sharing options...
akitchin Posted May 3, 2007 Share Posted May 3, 2007 you can simply name the input containing player IDs as an array: echo "<input name='playerID[]' type='hidden' value='" . $player['playerID'] . "'"; the resulting IDs will then be in the $_POST['playerID'] array. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted May 3, 2007 Share Posted May 3, 2007 I'm pretty sure you can't pass an array in the POSTarray, but you might be able to do something, do the query to get the information, then do a foreach or while loop and echo a new hidden input field, with the name of something like: <input type="hidden" name="playerID[]" value="$row['playerID']" /> I don't really know since I've never tried this, but it could work. Look on php.net and google, they might help. edit: D'oh, beat to it. Well, there you go. Quote Link to comment Share on other sites More sharing options...
rbragg Posted May 3, 2007 Author Share Posted May 3, 2007 akitchin, it's getting there! I named all of the inputs as arrays, ie. hits[]. Now my information is stored within the POST array for each input. The problem I have now is that the playerID is not associating itself with the input. Instead of having say (for playerID# 5): [hits] => Array ([5] => 3 I have: [hits] => Array ([0] => 3 It increments from 0 to 16. I know I must associate the playerID somehow with each input but I'm not sure how to go about that. I'm sure there is some trick. Quote Link to comment Share on other sites More sharing options...
rbragg Posted May 3, 2007 Author Share Posted May 3, 2007 Ok I think this is how it's supposed to be. I do have a problem somewhere, though. I just haven't figured out what it is yet. LOL! Will let you guys know. Quote Link to comment Share on other sites More sharing options...
akitchin Posted May 4, 2007 Share Posted May 4, 2007 you can try using the playerID as the index in each of the inputs: <td align='center'><input name="hits[<?php echo $player['playerID']; ?>]" type="text" size="3" maxlength="3" value="0" class="style3" /></td> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.