<< Back to embedding reports

Embed SQL Results Output

You can run report output without having to create a report. Just set the reportico project that relates to the database you want to run against (using the initial_project parameter) and use the initial_sql parameter to provide the SQL query. Note you cannot use the SELECT * notation in Reportico, you have to specify report columns.
Notice how column aliases in the SQL are used to set column titles.

    require_once("path/to/reportico.php");        // Include Reportico
    $q = new reportico();                         // Create instance
    $q->initial_execute_mode = "EXECUTE";
    $q->access_mode = "REPORTOUTPUT";
    $q->initial_project = "northwind";
    $q->initial_project_password = "password"; // If project password required
    $q->initial_sql = "SELECT CustomerID AS Id, companyname as company, contactname as contact_name FROM customers";
    $q->set_attribute("ReportTitle","Customer List");
    $q->clear_reportico_session = true;
    $q->execute();

Note the use of the set_attribute function to set the report title. You can hide the report title instead using the call :-

$q->output_template_parameters["show_hide_report_output_title"] = "hide";

Customer List

  Output: HTML PDF CSV
Style Table Form
Show
 
Unable To Continue:
Notice: A non well formed numeric value encountered
Main Report Query - Error: Query Failed

SELECT CustomerID AS Id, companyname as company, contactname as contact_name FROM customers

Status 0 -