Re: Basic Dual Query Combine into one question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 29, 2015, at 4:29 PM, Christoph Becker <cmbecker69@xxxxxx> wrote:

> Assuming that $test_result->getRecords() returns an array[1], you could
> do the following:
> 
>  <?php
>  $records = $test_result->getRecords();
>  // sort by last name
>  usort($records, function ($a, $b) {
>      return strcmp(
>          $a->getField('Contact_Last'),
>          $b->getField('Contact_Last')
>      );
>  });
>  ?>
>  <?php foreach ($records as $test_row) { ?>
>  <!-- the rest as before -->
> 
> -- 
> Christoph M. Becker

YIPPEE THAT WORKED!!!!!!!!!!!! THANK YOU SO MUCH Christopher!!!!!


<?php
 $records = $test_result->getRecords();
 // sort by last name
 usort($records, function ($a, $b) {
     return strcmp(
         $a->getField('Contact_Last'),
         $b->getField('Contact_Last')
     );
 });
 ?>
 
 
 <?php foreach ($records as $test_row) { 
 ?>
  <?php echo $test_row->getField('ID'); ?> 
      <?php echo $test_row->getField('Contact_Last'); ?> 
      <?php echo $test_row->getField('State'); ?>
      <br />
 <?php
  }
 ?>

!SUPER!

Q: I think when I tried to sort on numeric field is came back as text type sort...

Is there  a way to designate a numeric sort on certain fields?

see... when sort on numeric id field...

187 xxx      
200 xxx      
201 xxx     
21 xxx     
22 xxx     
222 xxx 
224 xxx
etc...

Q: Is it also possible to sort a more than 1 field like sort on Contact_Last & also State field at same time?

--
Thanks,
Dave - DealTek
dealtek@xxxxxxxxx
[db-15]


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux