0
我試圖創建的每個結果我從我的SQL查詢得到的條形碼。 基本上我有在HTML表格示出了結果,並且在最後一列我想這樣顯示的條形碼=到$行的值= [1]。我完全喪失瞭如何做到這一點。PHP查詢結果與條碼圖像
<?php
//PHP Includes
include('inc/database.php');
require_once('class/BCGFontFile.php');
require_once('class/BCGColor.php');
require_once('class/BCGDrawing.php');
require_once('class/Barcode39.php');
header('Content-Type: image/png');
// MSSQL Query
$sql = "SELECT warehouse, pick_order_number, order_status, pick_order_type, customer_order_number
FROM pick_order_header
WHERE warehouse = 'XDGM'
AND order_status <> 'Complete'
AND order_status <> 'Closed'
AND pick_order_type <> 'Backorder'";
?>
<!DOCTYPE HTML>
<link rel="stylesheet" type="text/css" href="css/master.css">
<html>
<title>Current Orders</title>
<body>
<table>
<?php
// SQLSRV Query
$results = sqlsrv_query($conn, $sql);
if($results === false) {
die(print_r(sqlsrv_errors(), true));
}
echo "
<table border=1>
<tr>
<th>Order Number</th>
<th>Order Status</th>
<th>Order Type</th>
<th>Customer Order</th>
<th>Barcode</th>
</tr>";
while ($row = sqlsrv_fetch_array($results))
{
$odrnum = $row[1];
$odrstatus = $row[2];
$odrtype = $row[3];
$custorder = $row[4];
$barcode = $row[1];
echo "
<tr>
<td>$odrnum</td>
<td>$odrstatus</td>
<td>$odrtype</td>
<td>$custorder</td>
<td>$barcode</td>
</tr>";
}
echo "</table>";
?>
</table>
</body>
</html>
要創建我知道我需要有
$code = new BCGcode39(); // Or another class name from the manual
$code->setScale(2); // Resolution
$code->setThickness(30); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
$code->parse('HELLO'); // Text
$drawing = new BCGDrawing('', $colorfg);
$drawing->setBarcode($code);
$drawing->draw();
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
在哪裏,我想看到條碼條碼是
<td>$barcode</td>
我只是對如何實現它沒有線索。
非常感謝您的回覆,我來看看使用這種方法超出內存允許,因爲是搶了許多畫。所以現在我感興趣的是將文件保存在服務器上,然後引用它們。您是否介意幫助我處理該場景 – eternityhq
如果您閱讀http://www.barcodephp.com/en/userguide,您會看到BCGDrawing :: __構造的第一個參數恰恰是一個文件名,所以我想如果您使用該參數參數,draw方法應該將條碼留在該文件中,然後您可以簡單地使用該文件作爲img src。你應該注意到,如果這一切都改變了,你可能不會解決你的記憶問題。你應該研究一些重新使用BCGDrawing對象,並緩存圖像(爲了不產生兩次相同的圖像) – Muc
謝謝你是非常有幫助的。 – eternityhq