php部分:網頁中報表的列印

來源:互聯網
上載者:User

標籤:function   code   head   post   cin   script   table   nat   php   

網頁中報表的列印,是通過調用window對象中的print()方法實現列印功能的;

呼叫瀏覽器本身的列印功能實現列印

<a href="#" onclick="window.print()">列印</a>

主要頁面代碼:查詢nation表

<body>    <table border="1" cellspacing="0" cellpadding="0">        <tr><th>代號</th><th>名稱</th></tr>        <tbody id="neirong"></tbody>    </table>    <a href="#" onclick="window.print()">列印</a></body></html><script type="text/javascript">    $.ajax({        type:"post",        url:"chuli.php",        async:true,        dataType:"TEXT",        success:function(data)        {            var hang=data.split("|");            var str="";            for(var i=0;i<hang.length;i++)            {                var lie=hang[i].split("^");                str=str+"<tr><td>"+lie[0]+"</td><td>"+lie[1]+"</td></tr>";            }            $("#neirong").html(str);        }    });</script>

處理頁面代碼

<?phpinclude("../../gongju/DBDA.class.php");$db=new DBDA();$sql="select * from nation";echo $db->StrQuery($sql);?>

 

以上的內容,是列印瀏覽器顯示頁面所有的內容,但往往很多內容是不需要列印的,所以要加控制,用css樣式控制列印內容

<style>@media print {  .noprint { display: none } } </style></head><body><p>我是需要列印的內容。但是不想列印出按鈕</p><button class="noprint" onclick="window.print()">列印文本</button></body>

 

php部分:網頁中報表的列印

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.