Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 23/11/2024 Black Friday 2024

    BIG SALE, 30% discount for all our extensions. Use BF24 coupon code. Hurry up the discount is valid till 3 December.

  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

Sorting tables by column values
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Sorting tables by column values
#29040
Sorting tables by column values 12 Years, 5 Months ago Karma: 0
Currently the results displayed in our table are sorted Alphabetically a-z (I'm assuming this is by default).

How do I sort the tables by the value of another column, either ascending or descending.

Example: go to www.yousaygo.com and enter the zip code 22601. click "where" menu item. I want to sort the results by the distance column, ascending from shortest distance to farthest.

Second example: another table will have events displayed in a similar fashion. How can I sort the events chronologically (based on dates in the database) from most upcoming to furthest in the distance?

Thanks in advance,

Jessy
sbi
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#29046
Re:Sorting tables by column values 12 Years, 5 Months ago Karma: 760
Hello,

What plugin code do you use for tables?

Regards,
ARI Soft
The administrator has disabled public write access.
 
#29077
Re:Sorting tables by column values 12 Years, 5 Months ago Karma: 0
Here is what is currently in use for the table that needs to be chronologically sorted (most upcoming first) by date of the event
{arijdatatable bPaginate="true"; iDisplayLength="5"; sPaginationType="full_numbers"; bAutoWidth="false"; oLanguage_sZeroRecords="No events to display." }
{arisqltable}
{arisqltablecolumns}
{arisqltablecolumn id="Image" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="Venue" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="Event" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="eLink" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="vLink" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="Date" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="Time" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn alias="When" virtual="true" pos="1"}
{coltemplate}{$Date} @ {$Time}{/coltemplate}
{/arisqltablecolumn}
{arisqltablecolumn alias="What" virtual="true" pos="2"}
{coltemplate}<img src="images/events/{$Image}" width="40" height="30" /><a href="{$eLink}">{$Event}</a>{/coltemplate}
{/arisqltablecolumn}
{arisqltablecolumn id="Summary" }{/arisqltablecolumn}
{arisqltablecolumn alias="Where" virtual="true" pos="4"}
{coltemplate}<a href="{$vLink}">{$Venue}</a>{/coltemplate}
{/arisqltablecolumn}
{/arisqltablecolumns}
{arisqltablequery}SELECT venue.venue_name AS Venue, venue.link AS vLink, events.event_name AS Event, events.summary AS Summary, events.link AS eLink, events.image AS Image, date_format(events.start, '%b %e') as Date, date_format(events.start, '%l:%i %p') as Time, venue.gpoint FROM #__ysg_events AS events INNER JOIN #__ysg_venue AS venue
ON events.vid = venue.id WHERE MBRContains( GeomFromText( 'POLYGON((<?php echo $western.' '.$southern.', '.$eastern.' '.$southern.', '.$eastern.' '.$northern.', '.$western.' '.$northern.', '.$western.' '.$southern; ?>))' ) , venue.gpoint ) {/arisqltablequery}
{/arisqltable}
{/arijdatatable}


____________________________________________

And this is for the table that needs to be sorted by distance column (shortest distance first)
{arijdatatable bPaginate="true"; iDisplayLength="10"; sPaginationType="full_numbers"; bAutoWidth="false"; oLanguage_sZeroRecords="No venues found."}
{arisqltable}
{arisqltablecolumns}
{arisqltablecolumn id="Image" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="Venue" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn id="Link" hidden="true"}{/arisqltablecolumn}
{arisqltablecolumn alias="Where" virtual="true" pos="1"}
{coltemplate}<img src="images/venues/{$Image}" width="40" height="30" /><a href="{$Link}">{$Venue}</a>{/coltemplate}
{/arisqltablecolumn}
{arisqltablecolumn id="Summary"}{/arisqltablecolumn}
{arisqltablecolumn id="Distance"}{/arisqltablecolumn}
{/arisqltablecolumns}
{arisqltablequery saveTags="true"}
SELECT venue.id, venue.venue_name AS Venue, venue.gpoint, venue.summary AS Summary, venue.link AS Link, venue.image AS Image, venue.lat, venue.long, FORMAT( 3956 *2 * ASIN( SQRT( POWER( SIN( ( <?php echo $location['latitude']; ?> - venue.lat ) * pi( ) /180 /2 ) , 2 ) + COS( <?php echo $location['latitude']; ?> * pi( ) /180 ) * COS( venue.lat * pi( ) /180 ) * POWER( SIN( (<?php echo $location['longitude']; ?> - venue.long) * pi( ) /180 /2 ) , 2 ) ) ) , 2 ) AS Distance
FROM #__ysg_venue AS venue WHERE MBRContains( GeomFromText( 'POLYGON((<?php echo $western.' '.$southern.', '.$eastern.' '.$southern.', '.$eastern.' '.$northern.', '.$western.' '.$northern.', '.$western.' '.$southern; ?>))' ) , venue.gpoint )
{/arisqltablequery}
{/arisqltable}
{/arijdatatable}
sbi
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#29081
Re:Sorting tables by column values 12 Years, 5 Months ago Karma: 760
You can use ORDER BY clause in an SQL query.

Regards,
ARI Soft
The administrator has disabled public write access.
 
#29085
Re:Sorting tables by column values 12 Years, 5 Months ago Karma: 0
We've tried using that clause and the sort did not seem to change. Any thoughts as to why? An example of how it should be properly executed when using ARI smart content?

Thanks!
sbi
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#29088
Re:Sorting tables by column values 12 Years, 5 Months ago Karma: 0
Just tested it again and the table sorts by the first column, regardless of query ORDER BY. This functionality is crucial to our implementation.
sbi
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 12