Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LadyDeathKZN's avatar

Load Data for Month Selected

Hi, I am building an application with financial records. My client wants to be able to select a Month and have those "slips" show and have just those exported to an excel.

I currently have a month_id for the slips, and the months are entered manually. Is there a way to have a dropdown with the months and when toggled the table will find the month_id and show only that data? I have tried numerous things and find myself to be still a noob with this. Also how does one export that months data to an excel or pdf?

0 likes
3 replies
mvd's avatar
mvd
Best Answer
Level 48

Hi @ladydeathkzn,

With this query you can get the months from the database to an array.

  $months = DB::table("your_table_name_with_the_financial_records")
    ->select(DB::raw('monthname(created_at) AS month'))
    ->orderBy('created_at')
    ->groupBy(DB::raw('month'))
    ->get()
    ->toArray();
dd($months);
artcore's avatar

I've been using https://bootstrap-table.com/ in combination with http://www.daterangepicker.com/ On change let the bootstraptable send a query with start and end dates. In your controller you can fetch that in the Request params and than send back the data as json. You have to create your array items in such manner that each row has subsequent monthly data. It's straightforward but if you're not too experienced will take a bit of effort and persistence, but these tools work nicely :) BTW bootstraptable supports excel export as well as pdf, csv and others

Please or to participate in this conversation.