Answer the question
In order to leave comments, you need to log in
How to implement the display of the previous slide on the ajax slider?
Hello, I'm making a jquery / ajax slider, I need a self-writing (do not offer plugins) with the "forward" function, everything worked out, but the backward function stupidly takes the very first slide.
I'm using laravel Naturally, it takes the first slide because first() looks for the first smallest one. If you use get (), then a bunch of slides with the smallest id will come, which is also not necessary in essence. Need hints
Route::post('/gtc/next', function() {
$id = trim(Input::get('id'));
$id = htmlspecialchars($id);
$id = stripcslashes($id);
$slider_data = Slides::where('id', '>', $id) -> first();
$slider_item = DB::table($slider_data['item_type']) -> where('id', '=', $slider_data['item_id']) -> first();
return array("part" => $slider_item, "id" => $slider_data['id'], 'prev_id' => $id);
});
Route::post('/gtc/prev', function() {
$id = trim(Input::get('id'));
$id = htmlspecialchars($id);
$id = stripcslashes($id);
$slider_data = Slides::where('id', '>', Input::get('prev_id')) -> first();
$slider_item = DB::table($slider_data['item_type']) -> where('id', '=', $slider_data['item_id']) -> first();
return array("part" => $slider_item, "id" => $slider_data['id'], 'prev_id' => $id);
});
Answer the question
In order to leave comments, you need to log in
what for each time to pull out from basis?
you can’t just pull everything out, and already on the page send them to Narnia?
so the slide itself will be easier to organize.
if it's just queries, then here's the code
next - select * from slides where id > $cur_id limit 1
previous -
select * from slides where id < $cur_id order by desc limit 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question