KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to use user input query to display a report? #36

Open zenon opened this topic on on Jul 22, 2017 - 4 comments

zenon commented on Jul 22, 2017


How to capture user input as a query instead of writing the query backend to display out a report?


KoolReport commented on Jul 22, 2017

Well, it is easy as you create a <form> with <textarea> to input statement. On the form submit, you get the the value of textarea which is the sql statement. Insert that value into report

$report = new MyReport(array(

In the setup() function, you can get the sql through $this->params["sql"].

Although this is not recommended to expose the sql statement at client-side like this but for personal use, why not.

Hope that helps.


zenon commented on Jul 24, 2017

Thank you very much.

Is it possible to change the columns displayed in report view automatically based on the sql statement? This is because different sql statement have different report display. How to do it with kool report?


KoolReport commented on Jul 24, 2017

You can, in the \koolreport\widgets\koolphp\Table, if you do not specified any column name in "columns" settings, it will display all available columns. So when you change SQL Statement, the Table just display all columns it receives.

zenon commented on Jul 24, 2017

Got it! Thanks.

1) But how can I change/customize the layout of the table of a report without taking exactly the result of the sql statement? 2) And how to allow the table to display value with decimal places? In my sql statement, there are decimal places, but the value did not display as value with decimal places.


Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed