I am reasonably new to PHP but have been stuck on this for days. Basically, I have a fishing website that has two databases. One is for personal bests and one for all time records. Now, I thought it would be simpler to have just the one table, with everyones personal best and then I could use a PHP/SQL script to retrieve the all time records.
Problem is, it retrieves the name of the fish and and highest weight caught but yet always displays the one person, not the correct person who caught it.
Table consists of the fields basically like Species, FishName, Rank, Weight (Drams), Angler, Peg, DateCaught.
The SCRIPT is
$query = "SELECT Type, Name, Rank, Person, MAX(Drams) as Drams FROM table GROUP BY Name ORDER BY Type ASC, Rank ASC";
$result = mysql_query($query) or die(mysql_error());
echo "<b>Testing a display of All Time Records from PB Table.</b> <br>";
while($row = mysql_fetch_array($result)){
echo "Records for ". $row['Type']. " with name ". $row['Name']. " weighs ". $row['Drams']. " caught by ". $row['Person'];
echo "<br>";
}
mysql_close($con);
What should happen is a list will now produce showing each Name for a fish and the weight that they were caught, and who caught it as in Example 1 but example 2 is happening instead.
Example 1:
Records for Carp with name Piggy weighs 1024 caught by David Bloggs
Carp with name Flipper weighs 123 caught by Arthur Smith
Example 2:
Records for Carp with name Piggy weighs 1024 caught by David Bloggs
Carp with name Flipper weighs 123 caught by Arthur Smith