【发布时间】:2016-01-27 10:52:14
【问题描述】:
我想将学生编号'2014000030' 作为参数值传递,以便我只获取该学生的报告。我如何使用代码下方的 sql 查询来做到这一点。下面的代码是我如何做到的,但它不起作用,我哪里出错了?
PHP 代码
<?php
//Import the PhpJasperLibrary
include_once('PhpJasperLibrary/tcpdf/tcpdf.php');
include_once("PhpJasperLibrary/PHPJasperXML.inc.php");
//database connection details
$server="localhost";
$db="student_portal";
$user="root";
$pass="";
$version="0.8b";
$pgport=5432;
$pchartfolder="./class/pchart2";
$value = '2014000030';
//display errors should be off in the php.ini file
ini_set('display_errors', 0);
//setting the path to the created jrxml file
$xml = simplexml_load_file("test.jrxml");
$PHPJasperXML = new PHPJasperXML();
//$PHPJasperXML->debugsql=true;
$PHPJasperXML->arrayParameter=array("parameter1"=>$value);
$PHPJasperXML->xml_dismantle($xml);
$PHPJasperXML->transferDBtoArray($server,$user,$pass,$db);
$PHPJasperXML->outpage("I"); //page output method I:standard output D:Download file
?>
SQL 查询
SELECT i.stid,i.surname,i.first_name,i.other_names,i.dob,i.course,b.branch_name,r.exam_no,r.modules,m.module_name,r.result,rr.remark FROM modules m,info i,results r,branches b,result_remarks rr WHERE r.modules=m.module_code AND i.campus_code=b.branch_code AND i.stid=r.stid AND rr.result=r.remark
【问题讨论】:
-
最终这应该是 i.stid='2014000030',但我不知道如何将 PHP 中的值传递给报告。请帮助那家伙。谢谢
-
它是数据库表中的整数类型。我不确定你是否正确地回答了我的问题。我想将学生编号 2014000030 从 PHP 代码传递给 jaspereport,这样我就只能得到这个特定学生的报告。
标签: php jasper-reports parameter-passing