Jump to content

Need help with PhP site


daniel
 Share

Recommended Posts

Well first of all im trying to build a fantasy football website.. nothing very detailed.. its just a simple project for a class.... so what im trying achieve at this point is to be able to select players from a list that will be shown of players.. and being able to select them into a team and each player has a price and a each team has a price limit.

This is what i have done right now (so what i need help with is to be able to click on the player names displayed, and choose them and save them on another table.)

 

<html>
<body>
<table border='1' align='right'>
<tr>
<td>
<form action="fantasy.php" method="get">
<b>Order by:</b>
<br>
<input type="radio" name="order" value="cost">Cost
<br>
<input type="radio" name="order" value="points">Points
<br>
<input type="radio" name="order" value="name">Name
<br>
<input type="radio" name="by" value="ASC">Ascending
<br>
<input type="radio" name="by" value="DESC">Descending
<br>
<b>Position:</b>
<br>
<select name="position">
 <option selected value ="all">Show All</option>
 <option value ="WHERE position = 'Goalkeeper'">Goalkeepers</option>
 <option value ="WHERE position = 'Defender'">Defenders</option>
 <option value ="WHERE position = 'Midfield'">Midfielders</option>
 <option value ="WHERE position = 'Forward'">Forwards</option>
 <option value ="WHERE team = 'Deportivo Cali'">Deportivo Cali</option>
 <option value ="WHERE team = 'Deportes Quindio'">Deportes Quindio</option>
 <option value ="WHERE team = 'Nacional'">Atletico Nacional</option>
 <option value ="WHERE team = 'Atletico Huila'">Atletico Huila</option>
 <option value ="WHERE team = 'Pereira'">Deportivo Pereira</option>
 <option value ="WHERE team = 'Medellin'">Independiente Medellin</option>
 <option value ="WHERE team = 'La Equidad'">La Equidad</option>
 <option value ="WHERE team = 'Millonarios'">Millonarios</option>
 <option value ="WHERE team = 'Tolima'">Deportes Tolima</option>
 <option value ="WHERE team = 'Pasto'">Deportivo Pasto</option>
 <option value ="WHERE team = 'Junior'">Atletico Junior</option>
 <option value ="WHERE team = 'Once Caldas'">Once Caldas</option>
 <option value ="WHERE team = 'Chico'">Chico FC</option>
 <option value ="WHERE team = 'Real Cartagena'">Real Cartagena</option>
 <option value ="WHERE team = 'Santa Fe'">Santa fe</option>
 <option value ="WHERE team = 'Cucuta'">Cucuta Deportivo</option>
 <option value ="WHERE team = 'Bucaramanga'">Atletico Bucaramanga</option>

</select>
<input type="submit" value="Submit">
</form>
</td>
</tr>
</table>
<br>
<br>
<br>
<?php
$con = mysql_connect("localhost","root");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("fantasy", $con);
if($_GET['position'] == 'all') {
$position = "";}
else { $position = $_GET[position];}
$query= "SELECT * FROM players  ".$position." ORDER BY '".$_GET['order']."' ".$_GET['by'].",'position','name'";

$result = mysql_query($query);


echo "<br><table border='1' align='right'>
<tr>
<th>Name</th>
<th>Team</th>
<th>Position</th>
<th>Cost</th>
<th>Points</th>
</tr>";

while($row = mysql_fetch_array($result))
 {
 echo "<tr>";
 echo "<td>" . "<a href=fantasy.php?manid=".$row['id']."&action=addtoteam>".$row['name']."</a>" . "</td>";
 echo "<td>" . $row['team'] . "</td>";
 echo "<td>" . $row['position'] . "</td>";
 echo "<td>" . $row['cost'] . "</td>";
 echo "<td>" . $row['points'] . "</td>";
 echo "</tr>";
 }
echo "</table>";
echo $query;
mysql_close($con);
?>
</FORM>
</body>
</html>

 

Any help is appreciated,

thx,

dan

Edited by daniel

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...