Answer the question
In order to leave comments, you need to log in
How to add record sequence number field in SQL query?
There is a request:
$users = DB::table('users')
->whereBetween('votes', [20, 100])
->orderBy('votes', 'desc')
->paginate(10);
Answer the question
In order to leave comments, you need to log in
$i = ($page_num*10)-1;
foreach(){
$i++;
echo $i;
}
With such a request, it will return all columns to you. Therefore, if you have an ID field in your table, then you can output it as
foreach($users as $user){
echo $user->id;
}
@foreach($users as $user)
{{ $user->id }}
@endforeach
$users = DB::table('users')
->select('id', 'rank')
->whereBetween('votes', [20, 100])
->orderBy('votes', 'desc')
->paginate(10);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question