使用PHP生成PDF文件的问题

时间:2014-03-28 21:22:54

标签: php pdf

我正在尝试从我的数据库中的费用表生成PDF报告,但不断收到错误:

Warning: mysqli_query() expects parameter 1 to be mysqli, null given on line 79
Error: 
Query: SELECT * from expenses

function Table($query,$prop=array())
{
    //Issue query
    LINE 79 =   $res=mysqli_query($db_connection, $query) or die('Error: '.mysql_error()."<BR>Query: $query");
    //Add all columns if none was specified
    if(count($this->aCols)==0)
    {
        $nb=mysql_num_fields($res);
        for($i=0;$i<$nb;$i++)
            $this->AddCol();
    }

其他PHP文件         //连接数据库     包括(&#34; connect.php&#34);     //的mysql_connect(&#39;本地主机&#39;&#39;根&#39;&#39;&#39);     // mysql_select_db(&#39; classicmodels&#39);

$pdf=new PDF();
$pdf->AddPage();
//First table: put all columns automatically
$pdf->Table('SELECT * from expenses');
$pdf->AddPage();
//Second table: specify 3 columns
$pdf->AddCol('id',40,'','C');
$pdf->AddCol('user_id',40,'expenses','C');
$pdf->AddCol('currency',40,'type','C');
$prop=array('HeaderColor'=>array(255,150,100),
            'color1'=>array(210,245,255),
            'color2'=>array(255,255,210),
            'padding'=>2);
$pdf->Table('select user_id,  amount, currency from expenses order by id limit 0,10',$prop);

0 个答案:

没有答案