Thanks. Do you mind looking at this for me? I entered data into the table ratings for a sample match, so the output SHOULD give me the 14 players that I set to have played in that match, in order of how I entered them, but instead it is giving me them in order of their player_id. I have two tables, TABLE ratings and TABLE players.
player_id is found in TABLE players, but in TABLE ratings I have 14 fields titled player_id1, player_id2, and so on. Each of them have a value that corresponds with a number in the player_id field in TABLE players. IE Joe Smith player_id = 2. Then in the TABLE ratings for the first match, player_id1 = 2. Thus, it should be Joe Smith, but instead it is giving me Bob Jones first because his player_id = 1, even though in the TABLE ratings he is in player_id2.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="POST" name="theform" id="theform">
<table>
<tr>
<td colspan="2">latest match.</td>
</tr>
<?
// includes
include("linktoconfigurationfile.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
$query = "SELECT p.player_fname AS fname,
p.player_lname AS lname,
p.player_id AS playerid,
r.player_id1,
r.player_id2,
r.player_id3,
r.player_id4,
r.player_id5,
r.match_id
FROM
ratings r,
players p
ORDER BY
r.match_id,
r.player_id1,
r.player_id2,
r.player_id3,
r.player_id4,
r.player_id5 DESC LIMIT 0, 5";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print article titles
$i=1;
while($row = mysql_fetch_object($result))
{
?>
<tr>
<td><input type="hidden" name="player_id1" value="<?php echo $player_id1; ?>"><? echo $row->lname; ?> <? echo $row->fname; ?>
</td>
<td> <select name="value<?php echo $i; ?>">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</td>
</tr>
<?php
$i++; // increment $i
}
?>
<?
}
// if no records present
// display message
else
{
?>
<font size="-1">no players currently available</font>
<?
}
// close database connection
mysql_close($connection);
?>
<tr>
<td colspan="2">
<input type="Submit" name="submit" value="Update">
</td></tr>
</form>
</table>
</body>
</html>