I want to select all even posts id's from a table in my MySQL db and then display them. I also want to get all posts with odd id's and display them somewhere else.
I want to do this with PHP since that is the server-side language I am using.
Alternatively, would I have to select all posts and then check if they are even/odd with JavaScript? I would prefer PHP, but if it works with JavaScript that would be fine too.
Example of what I want:
table:
==================================================
id | text
==================================================
==================================================
| 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
==================================================
| 2 | turpis quis aliquet commodo, urna quam viverra justo, in |
==================================================
| 3 | Etiam in lectus sem. Nullam molestie nisl vel nunc consectetur |
==================================================
| 4 | Vestibulum eu molestie sapien. Ut luctus nulla vel libero sagittis |
==================================================
my failed attempt at a table in stackoverflow ^^
I want to display the even ones first, and the odd ones second:
Even Rows:
turpis quis aliquet commodo, urna quam viverra justo, in
Vestibulum eu molestie sapien. Ut luctus nulla vel libero sagittis
Odd Rows:
Lorem ipsum dolor sit amet, consectetur adipiscing elit
Etiam in lectus sem. Nullam molestie nisl vel nunc consectetur