Jump to content

Group different results together if date (not time) is the same?


Kristoff1875

Recommended Posts

Currently i'm using the following:

SELECT res.*, u.*, t.*
FROM Results res
INNER JOIN Users u USING (UserID)
INNER JOIN Teams t USING (TeamID)
WHERE RaceID = '$RaceID' AND Position = '1'

Which is getting race details.

<div class="ScheduleRace" style="background-image:url(images/tracks/<?=$row['Image']?>.jpg);">
    <div class="topstrip">
    <div style="float:left;"><?= 'Raceday '.$row['Raceday'].' - Race '.$row['RaceNum'].'. <strong>'; if ($row['Title'] !== '') { echo $row['Title'].' '; } echo $row['Track'].'</strong></div><div style="float:right;">'.date("d/m/Y - H:i", strtotime($row['Date'])).'</div><div style="clear:both;"></div>';?>
    </div>
    </div>

Each raceday consists of 3 races, the track, date, raceday is the same, but the times change. Do I need to have a second while inside this one to have the individual race details to group them together as follows:

<div class="ScheduleRace" style="background-image:url(images/tracks/<?=$row['Image'];?>.jpg);">
<?='Raceday '.$row['Raceday'].' - '.date("d/m/Y - H:i", strtotime($row['Date'])).'; if ($row['Title'] !== '') { echo $row['Title'].' '; } ?>

  //SECOND WHILE STATEMENT HERE

    <div class="topstrip">
    <div style="float:left;"><?= 'Race '.$row['RaceNum'];?></div>
    <div style="float:right;"><?= '.date("H:i", strtotime($row['Date']));?></div>
    </div>

    <div class="topstrip">
    <div style="float:left;"><?= 'Race '.$row['RaceNum'];?></div>
    <div style="float:right;"><?= '.date("H:i", strtotime($row['Date']));?></div>
    </div>

    <div class="topstrip">
    <div style="float:left;"><?= 'Race '.$row['RaceNum'];?></div>
    <div style="float:right;"><?= '.date("H:i", strtotime($row['Date']));?></div>
    </div>
  

</div>

Or is there a way to group the date and image and still loop the rest of the results inside the divs produced?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.