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 Link to comment https://forums.phpfreaks.com/topic/78877-solved-help-with-php-table-from-mysql-query/ 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. Link to comment https://forums.phpfreaks.com/topic/78877-solved-help-with-php-table-from-mysql-query/#findComment-399230 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? Link to comment https://forums.phpfreaks.com/topic/78877-solved-help-with-php-table-from-mysql-query/#findComment-399236 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... Link to comment https://forums.phpfreaks.com/topic/78877-solved-help-with-php-table-from-mysql-query/#findComment-399241 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! Link to comment https://forums.phpfreaks.com/topic/78877-solved-help-with-php-table-from-mysql-query/#findComment-399249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.