Jump to content

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


Kristoff1875
Go to solution Solved by 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?

Edited by Kristoff1875
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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