Jump to content

Recommended Posts

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  :shy: , any ideas how i could do this though, or any other possible ways i could acchieve the same results.

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.