Here is my query, it works as coded, but it's not exactly what I am looking for output wise.

<?php
$result = mysql_query("SELECT racesforweek.racetype, racesforweek.racename, dynamicactivehorse.tOwner, left(Entries.RaceID, 4) As Race1, RIGHT(Entries.RaceID, 4) As Race2, Entries.HorseID, entries.Odds, retired.HorseName
FROM (dynamicactivehorse INNER JOIN (retired INNER JOIN Entries ON retired.ID = Entries.RealHorseID) ON dynamicactivehorse.dHorseID = Entries.HorseID) INNER JOIN playerschanging ON dynamicactivehorse.tOwner = playerschanging.pc_name
INNER JOIN racesforweek ON entries.raceid = racesforweek.racenum
WHERE entries.RaceID LIKE '$currentweek%' AND playerschanging.pc_Residency = 'nwrc' AND
(racesforweek.racetype = 'G3' OR
racesforweek.racetype = 'G2' OR
racesforweek.racetype = 'G1' OR
racesforweek.racetype = 'ST')",$sim)
or die(mysql_error());


while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>{$row}.{$row}</td>";
echo "<td>{$row}</td>";
echo "<td>{$row}</td>";
echo "<td>{$row}</td>";
echo "<td>{$row}</td>";
echo "<td>{$row}</td>";
echo "</tr>";
}

?>

It outputs something like this...

1234.1111 Person 1
1234.2222 Person 2
1234.1111 Person 3
1234.2222 Person 4

The output I would like is this...

1234.1111
Person 1
Person 3

1234.2222
Person 2
Person 4

Can someone point me in the right direction?

Thanks in advance for any assistance provided!!

You really can't output in that format directly without a lot of DOM commands. (Don't ask me about them, I won't be able to help.)

What you may want to do is find a sensible way to temporarily store the data within your script as you read it from the table, then process it as necessary to produce the sorted appearance. Either that, or rework your database structure to make it more conducive to the output you want. Either way, you're probably going to need more than 1 loop, and you'll probably need a nested loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.