Mr Chris Posted June 19, 2007 Share Posted June 19, 2007 Hi Guys, I have two tables players table: And an appearances table: Now each of the rows in the appearances table holds the player_id of the player that played in that shirt for a specific match. Now here’s my question. In my CMS I have written a function to get the players name into a dropdown box, but place the value (player_id) into the apperances table: The Function // Start function to pull out data for all function db_result_to_array($result) { $res_array = array(); for ($count=0; $row = mysql_fetch_array($result); $count++) $res_array[$count] = $row; return $res_array; } // Get the player names out of database where team_id = $team_id for match reports function get_player_names() { $query='SELECT player_id, player_name FROM players'; $result=mysql_query($query); if(FALSE==$result) return FALSE; if((0 || FALSE)==mysql_num_rows($result)) { return false; } else { $result=db_result_to_array($result); return $result; } } The Dropdown for player_one <select class="input" name="player_one" size="1" style="width: 145" tabindex="1"> <option value="" selected>player_one</option> <?php $type_array=get_player_names(); foreach ($type_array as $players) { print("<option value=\"".$players['player_id']."\">".$players['player_name']."</option>\n"); } ?> </select> Now this works great for INSERTING, but my problem is when I want to edit and UPDATE the data in the appearances table. Say I went to the URL: www.mywebsitedomainnamehereyes.com/index.php?appearances_id=2 I’d want to get the dropdown to look in the appearances table for the 2nd record and force the dropdown in this case to show the value Steve Daly and then edit it if needs be. Can anyone help me on this, as i'm not sure how to go about doing it. Thanks Chris Quote Link to comment https://forums.phpfreaks.com/topic/56166-function-keeping-values/ 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.