majormajor71 Posted November 26, 2007 Share Posted November 26, 2007 Hi all, A newbie php/mysql user here hoping to find a little bit of help from all you good fellows. I have a simple html table that returns the team names created by a user. $result = mysql_query("SELECT * FROM Team WHERE Cpt_ID='".$captain_id."'") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th></th> <th></th> <th>Team Name </th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo '<a href="player_add.php">Add Players</a>'; echo "</td><td>"; echo '<a href="player_remove.php">Remove Players</a>'; echo "</td><td>"; echo $row['team_name']; echo "</td></tr>"; } echo "</table>"; I would like then to be able to allow the user to add or delete players from the teams that he/she created. My problem is that I am unsure how to specify which team was selected to be modified. I understand how to pass variables through pages with sessions, but I do not know how the "player_add" or "player_remove" page will know which team was selected. I would be most grateful for any help at all. Thanks so much, and let me know if anything is unclear. Paul Quote Link to comment Share on other sites More sharing options...
rlindauer Posted November 26, 2007 Share Posted November 26, 2007 You can just pass a value to player_add.php so that player_add.php knows which team was selected. <?php echo '<a href="player_add.php?team='.$row['team_id'].'">Add Players</a>'; ?> You know, substitute the '.$row['team_id'].' for the actual id or value you want to pass. Quote Link to comment Share on other sites More sharing options...
majormajor71 Posted November 26, 2007 Author Share Posted November 26, 2007 So how would I call that value in the "add_player.php" page that is brought up with the next link? Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 26, 2007 Share Posted November 26, 2007 As rlindauer said you pass the value from the link <?php echo '<a href="player_add.php?team=Add">Add Players</a>'; echo '<a href="player_add.php?team=Remove">Remove Players</a>'; ?> And in player_add.php you keep get those value and do stuff what you want... <?php if (isset($_GET['team']) && $_GET['team']=="Add") { $you_want_to_add = $_GET['team']; echo "I selected $you_want_to_add"; } elseif (isset($_GET['team']) && $_GET['team']=="Remove") { $you_want_to_add = $_GET['team']; echo "I selected $you_want_to_add"; } else { echo "Nobody clicked on the link, that's why we are here "; } ?> Hope you get the idea... Quote Link to comment Share on other sites More sharing options...
majormajor71 Posted November 26, 2007 Author Share Posted November 26, 2007 Thanks so much guys! i now understand what is meant by passing arguments through the address bar! It works perfectly now, you guys are awesome! 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.