That works great when the results are sorted in event order. but does not work when the results are not posted in order.
This is the code that im using in full;
<?php
$counter = array();
$eventid = '';?>
<?php do {
if ($eventid == ''){
$eventid = $row_view['results_eventid'];
$counter[$eventid] = 0;
// $counter = '0';
}
if ($eventid == $row_view['results_eventid']){
$counter[$eventid]++;
// $counter = $counter +1;
}
elseif ($eventid != $row_view['results_eventid']){
$eventid = $row_view['results_eventid'];
$counter[$eventid] = 1;
// $counter = 1;
}
?>
<div id="crew<?php echo $row_view['results_crewid']; ?>" <?php if ($counter.$eventid =='1'){?> class="winner"<?php }?>>
<div class="crewno <?php if ($counter.$eventid =='1'){echo " winner";}?>"><a href="#" name="crewno<?php echo $row_view['results_crewid'];?>" id="raceno<?php echo $row_view['results_crewid'];?>" onclick="showdetailedresults(<?php echo $id;?>,<?php echo $row_view['results_crewid']; ?>)" title="Detailed Results"><img src="images/detailed_icon.jpg" class="img_detail" alt="Detailed Results" /></a> <?php echo $row_view['results_crewid']; ?></div>
<div class="event <?php if ($counter.$eventid =='1'){echo " winner";}?>"><?php echo $row_view['results_eventid']; ?></div>
<div class="club <?php if ($counter.$eventid =='1'){echo " winner";}?>"><?Php echo $row_view['club_name'];?></div>
<div class="time<?php if ($counter.$eventid =='1'){echo " winner";}?>"><?php echo $row_view['results_time']; ?></div>
<div class="position <?php if ($counter.$eventid =='1'){echo " winner";}?>"><?php if ($counter== '1'){ echo "<strong>Winner</strong>";}else { echo $counter[$eventid];}?></div>
</div>
<?php } while ($row_view = mysql_fetch_assoc($view)); ?></div>
When i print the array it only seems to add the counter up when the events are listed after each other;
IE;
Event | TIME | POSITION
1 | 2.22.79 | 1
1 | 2.38.95 | 2
4 | 3.44.11 | 1
4 | 3.45.64 | 2
2 | 4.3.97 | 1
3 | 4.5.83 | 1
2 | 4.8.54 | 1
3 | 4.24.04 | 1
2 | 4.24.48 | 1
So we can see that the event #2 & #3 does not seem to have addded to the counter.
Any ideas as to why?
Thanks