Show the highest number

6 posts by 3 authors in: Forums > CMS Builder
Last Post: February 11, 2015   (RSS)

By richo - February 10, 2015

I am trying to help a school display the House with the most house points at the end of each week.

There are 5 houses. How can I show the house with the highest points please? 

Any help would be appreciated.

Many thanks

John

By richo - February 10, 2015

Thanks for the reply. I guess I should read more!

I have also been trying to put:

The leaders are "House name" with "points score" points.

Help with this would be appreciated thank you.

John

Try something like this if you want just the top leader:  (You will need to substitute your variables for table and field names)

<?php // load the top points records assuming you only want the top leader
  list($houseRecords, $houseMetaData) = getRecords(array(
    'tableName'   => 'house', // or whatever the table name is
        'orderBy' => 'points+0 DESC' // bring highest points to top   
        'limit'       => '1',
    'allowSearch' => false,
  ));
  $topRecord = @$houseRecords[0]; // get first record only
?>
<div class="some-wrapper">
  The leaders are <?php echo $topRecord['name'] ?> with <?php echo $topRecord['name'] ?> points.
</div>

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By richo - February 11, 2015

Thank you for your help.

It works a treat.

Happy to help!

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987