【问题标题】:Generating an XML table from mysql database using CodeIgniter使用 CodeIgniter 从 mysql 数据库生成 XML 表
【发布时间】:2019-04-08 12:09:19
【问题描述】:

HTML 中的这段代码有什么问题(Codeigniter 视图)?它应该从数据库销售发票信息生成一个VML文件。

<?php
    $this->load->helper('xml');
    $this->load->dbutil();
    $this->load->helper('file'); 
    $this->load->database();

    $report = $query = $this->db->get('invoices_salesvan_warehouse');
    $new_report = $this->dbutil->xml_from_result($report);
    write_file(‘xml_file.xml’,$new_report); 
?>

【问题讨论】:

  • $report = $query = $this-&gt;db-&gt;get('invoices_salesvan_warehouse'); 看起来不对。尝试只做$query = $this-&gt;db-&gt;get('invoices_salesvan_warehouse'); 并设置$new_report =$this-&gt;dbutil-&gt;xml_from_result($query);
  • ‘xml_file.xml’ 你在这里使用什么样的报价?它不应该只是单引号吗? 'xml_file.xml' ?

标签: php xml codeigniter


【解决方案1】:

试试

  function getDataForXML(){

   return $query = $this->db->get('invoices_salesvan_warehouse');

}  

function getreport()
{
    $this->load->dbutil();
    $this->load->helper('file');
    $report = $this->getDataForXML();
    $new_report = $this->dbutil->xml_from_result($report);
    write_file('xmlfile.xml',$new_report);
} 

【讨论】:

  • 错误已解决。原因是 html 中 php 开始和结束标记的位置。谢谢。
猜你喜欢
  • 2011-02-23
  • 2012-10-24
  • 1970-01-01
  • 2014-06-14
  • 1970-01-01
  • 1970-01-01
  • 2011-08-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多