Jump to content

Recommended Posts

Hey,

 

Here is my code atm thanks to dragon_sa

<div id="content"> 
  <div id="playerlistform"> 
  <h2>Add player to transfer list</h2>
    <form action="transfers-script.php" method="post">
    <table width="500" border="0" cellspacing="10" cellpadding="5">
  <tr>
    <td>Player  
<?php
$sql = mysql_query("SELECT * FROM players WHERE teamname='Arsenal'");

echo '<select name="playername" id="playername">';
while($row = mysql_fetch_array($sql)){
$playername = $row['playername'];
?>
<option value="<?php echo $playername; ?>"><?php echo $playername; ?></option>
<?php
}
?>
    </td>
    
    <td>Asking Price 
    </td>
    <td>Type
    <select name="transfertype" id="transfertype">
    <option value="sale" selected="selected">Sale</option>
    <option value="loan">Loan</option>
    </select>
    </td>
    <td><input type="submit" value="Submit" /></td>
  </tr>
</table>
</form>
  </div>
  <div id="listedplayers">
  <h2>Listed Players</h2>
  <?php 
//check for update request
if (isset($_GET['transfer']))
{
$transfer=$_GET['transfer'];
  mysql_query("UPDATE players SET transferstatus='' 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=\"arsenal.php?transfer=". $row['playerID'] . "\">Change Status</a></td>";
  echo "</tr>";
   }
echo "</table>";

?>    
  
  </div>
  <p> </p>
</div>

 

Would I be able to make it so it displays different results based on who is logged in. For example, if the user is 'ManchesterUnited' it shows the results for 'Manchester United' and if the user is 'Arsenal' it shows the results for 'Arsenal'

 

I can get it to work when wanting different links to be displayed, though i get syntax errors galore when i try using if statements on the above lol

My if statements for links

<?php if($session->logged_in){
if($session->isManchesterUnited()){
      echo "<a href=\"../squad/manchester-united.php\">Players</a>";
  }
  if($session->isArsenal()){
      echo "<a href=\"../squad/arsenal.php\">Players</a>";
  } ?>

 

I have all my user levels created using my constants.php and session.php pages, and the page the above code is displayed on is called transfers.php

 

Anyone know how to go about doing this, or is there a better method i should be using?

 

A little idea of how the code should look would be greatly appreciated!

 

Thanks  :D

 

 

Link to comment
https://forums.phpfreaks.com/topic/240013-help-with-if-statements/
Share on other sites

$sql = mysql_query("SELECT * FROM players WHERE teamname='Arsenal'");

 

I'm not sure how you are setting your $_SESSIONS for users logged in. If you do have any user specific details stored in $_SESSION data, you could simply get them into std. variables and insert directly into the mysql_query.... EG:

 

$usersTeam = $_SESSION['users_team'];
$sql = mysql_query("SELECT * FROM players WHERE teamname='$usersTeam'");

 

 

Not sure if this is what you mean though?

Think thats what i wanted yeah, nice one.

 

I have a seperate file called session.php which has

 

<?php function isManchesterUnited(){
      return ($this->userlevel == MANCHESTER_UNITED_USER_LEVEL);
   }
   function isChelsea(){
      return ($this->userlevel == CHELSAE_USER_LEVEL);
   } ?>

Then i just include that file at the top. If that makes sense lol

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.