Jump to content

Recommended Posts

Back again with another newbie question.

 

Is it possible for me to have a submit button next to each result, so that i can change the transfer status for that particualr player to "unavailable"

 

For Example i would like the table to look like:

Name            Status          Remove Button

Player one      sale        button to change status

Player two      loan        button to change status

<?php 
$result = mysql_query("SELECT * FROM players WHERE teamname='Arsenal' and transferstatus='sale' or teamname='Arsenal' and 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>
</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 "</tr>";
  echo "</tr>";
  echo "</tr>";
  echo "</tr>";
  echo "</tr>";
  }
echo "</table>";

?>  

Any ideas?

there are many ways to do this depending on how you want to use it, the easiest would be to use GET but this can lead to issues depending on who has access to the page that can modify the database

 

here is the GET method assuming the unique id for a player in your table is playerID and the page is called player.php you can use what ever you have set it to in the database

 

<?php 
//check for update request
if (isset($_GET['transfer']) {
  $transfer=$_GET['transfer'];
  mysql_query("UPDATE players SET transferstatus='unavailable' WHERE playerID='$transfer'");
}

$result = mysql_query("SELECT * FROM players WHERE teamname='Arsenal' and transferstatus='sale' or teamname='Arsenal' and 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'>Remove</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=\"player.php?transfer=". $row['playerID'] . "\">Change Status</a></td>";
  echo "</tr>";
   }
echo "</table>";

?>  

 

 

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.