Skip to content
Advertisement

Laravel 7 previous and next records with alphabetical order

In my edit form, I want to add a button to save and edit the following user.

I am trying that the “next” button takes me to the next record in alphabetical order.

I have only managed to order by ID

JavaScript

Advertisement

Answer

You need to use the rank function of mysql and raw query

For previous record

JavaScript

For next record

JavaScript

And you need to set the mysql.strict to false in config/database.php

Or

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement