random display of Data gets sorted/ ordered by dataTables...
random display of Data gets sorted/ ordered by dataTables...
Hi!
I use DataTables to show different accomodations in my area.
All Data is from Database.
To get the data I use:
SELECT * FROM accomodation_table ORDER BY RAND()
When the page is loading,
I can see that the data is random in order as it should be, BUT after 1-2 seconds
the data gets sorted somehow different. NOW the data is in a special order.
https://leutasch.net/ferienwohnung/verzeichnis-ferienwohnungen-sommer.php
Looking at the page (see link above) you see accomodations with a Promotion Icon (heart symbol) all lined up first, THEN the other ones. That should not be so!
I have no clue where to look for a solution!
Can anyone give me a hint what happens after the data is drawn from Database?
This question has an accepted answers - jump to answer
Answers
did you try setting ordering: false in your datatables initialization?
https://datatables.net/reference/option/ordering
If that doesn't do it, you could try adding a hidden column to the datatable for a random index and assign that random index in your select statement
and then tell datatables to, by default, sort by that randomIndex column
Thank you so much!!
Great advice!
Solved it!