chrisidas Posted June 26, 2011 Share Posted June 26, 2011 Hey, I have a transfer list of players on one page, showing all the players that are set to transfer listed in my database. I want it so when a player clicks the "make offer" link next to the player, it takes them to a page where they can fill in a form making an offer for that player. I only want to have one transfer form page, but with a different display for each player using variables. I have this code to display a list of results from my database. <?php ]if (isset($_GET['transfer'])) { $transfer=$_GET['transfer']; mysql_query("SELECT * FROM transferlist WHERE playerID='$transfer'"); } $result = mysql_query("SELECT * FROM players WHERE transferstatus='sale' or transferstatus='loan' ORDER BY transferstatus"); echo "<table border='1' width='500' bordercolor='black' align='left'> <tr> <th width='150' align='center'>Name</th> <th width='25' align='center'>Position</th> <th width='25' align='center'>Rating</th> <th width='25' align='center'>Value</th> <th width='25' align='center'>Transfer Type</th> <th width='25' align='center'>Offer</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td width='25' align='centre'>" . $row['playername'] . "</td>"; echo "<td width='25' align='center'>" . $row['playerposition'] . "</td>"; echo "<td width='25' align='center'>" . $row['playerrating'] . "</td>"; echo "<td width='25' align='center'>" . $row['playervalue'] . "</td>"; echo "<td width='25' align='center'>" . $row['transferstatus'] . "</td>"; echo "<td width='25' align='center'><a href=\"transferrequest.php?". $row['playerID'] . "\">Make Offer</a></td>"; echo "</tr>"; } echo "</table>"; ?> I'm using this part of the code so that the page i go to will be specific to the row in the table <?php echo "<td width='25' align='center'><a href=\"transferrequest.php?". $row['playerID'] . "\">Make Offer</a></td>"; ?> On the page it links to the address will be "...transferrequest.php?(the playerID number) Now i was wondering, is it possible to take the playerID number from the address and use it as a variable. So i can make a form specific to the player the person selects? Not sure if that makes sense , any ideas how i could do this though, or any other possible ways i could acchieve the same results. Quote Link to comment https://forums.phpfreaks.com/topic/240433-is-it-possible-to-use-part-of-the-page-address-as-a-variable/ Share on other sites More sharing options...
wildteen88 Posted June 26, 2011 Share Posted June 26, 2011 Yes you can. However you'll need to modify your url slightly <?php echo "<td width='25' align='center'><a href=\"transferrequest.php?pid=". $row['playerID'] . "\">Make Offer</a></td>" Now you can get the player id from the url using $_GET['pid'] You can set variables within your urls in this format site.com/somepage.php?var1=value1&var2=value2&var3=value3 etc Quote Link to comment https://forums.phpfreaks.com/topic/240433-is-it-possible-to-use-part-of-the-page-address-as-a-variable/#findComment-1234952 Share on other sites More sharing options...
chrisidas Posted June 26, 2011 Author Share Posted June 26, 2011 Wooo! Cheers mate Quote Link to comment https://forums.phpfreaks.com/topic/240433-is-it-possible-to-use-part-of-the-page-address-as-a-variable/#findComment-1234957 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.