我正在尝试使用 php printer_write 函数来定位文本打印机中的文本,但我知道它不会那样工作。您能否建议我一些在表格或 div 中设置值的方法,以便它们有条理。
下面是我正在使用的代码。
<?php
include "connect.php";
include "links.php";
$date = DATE('D, d M, Y');
$i=1;
$getData = mysql_query("SELECT * FROM facturas");
$dataCount = mysql_num_rows($getData);
$handle = printer_open("Generic / Text Only");
printer_set_option($handle, PRINTER_MODE, "RAW");
printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_RIGHT);
printer_write($handle, $business_name . " " . $date);
printer_write($handle, "\n");
printer_write($handle, $street . ", " . $city);
printer_write($handle, "\n");
printer_write($handle, $phone);
printer_write($handle, "\n");
printer_write($handle, "-----------------------------------");
printer_write($handle, "\n");
printer_write($handle, "\n");
while($showData = mysql_fetch_array($getData)){
$serial = $showData['serial'];
$type = $showData['type'];
$model = $showData['model'];
$qty = $showData['qty'];
$price = $showData['price'];
printer_write($handle, $qty . " x " . $type . " " . $model . "....." . $price . "\n");
}
printer_write($handle, "\n");
printer_write($handle, "\n");
printer_write($handle, "\n");
printer_write($handle, "\n");
printer_write($handle, "\n");
printer_write($handle, "\n");
printer_write($handle, "\n");
printer_write($handle, "\n");
printer_close($handle);
?>
这段代码可以正常打印,但是循环中的printer_qire代码WHILE
只会打印每行上的所有内容,可以正常工作,但是如果有的话,我可以在表格中保存这些数据吗?
这是本地服务器中的练习代码,我知道 SQL 注入。
谢谢