คำตอบที่ได้รับเลือกจากเจ้าของกระทู้
ความคิดเห็นที่ 5
แก้ประมานนี้ครับ
[Spoil] คลิกเพื่อดูข้อความที่ซ่อนไว้
foreach ($result as $row) {
$barcode[$i] = null;
$aa = $row['croid'];
$sql2 = "SELECT * FROM `tbproadd` WHERE croid = '$aa'";
if ($result2 = mysqli_query($conn, $sql2)) {
while ($obj2 = mysqli_fetch_assoc($result2)) {
$barcode[$i] .= $obj2["barcode"]."<br>";
}
}
$table2 = '
<tbody>
<tr style="border:1px solid #000;padding:4px;">
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $i . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['croid'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['datecro'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">' . $row['customername'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">'.$barcode[$i].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $quantity[0]. '<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $unit[0].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: right; font-size:12pt ">' . $price[0].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['sales'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">' . $row['remark'] . '</td>
</tr>
</tbody>
';
$i++;
}
[Spoil] คลิกเพื่อดูข้อความที่ซ่อนไว้
foreach ($result as $row) {
$barcode[$i] = null;
$aa = $row['croid'];
$sql2 = "SELECT * FROM `tbproadd` WHERE croid = '$aa'";
if ($result2 = mysqli_query($conn, $sql2)) {
while ($obj2 = mysqli_fetch_assoc($result2)) {
$barcode[$i] .= $obj2["barcode"]."<br>";
}
}
$table2 = '
<tbody>
<tr style="border:1px solid #000;padding:4px;">
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $i . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['croid'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['datecro'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">' . $row['customername'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">'.$barcode[$i].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $quantity[0]. '<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $unit[0].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: right; font-size:12pt ">' . $price[0].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['sales'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">' . $row['remark'] . '</td>
</tr>
</tbody>
';
$i++;
}
▼ กำลังโหลดข้อมูล... ▼
แสดงความคิดเห็น
คุณสามารถแสดงความคิดเห็นกับกระทู้นี้ได้ด้วยการเข้าสู่ระบบ
สอบถามวิธี loop ใน loop ข้อมูลใน table mpdf ได้ไหมครับ
<?php include('./server/db.php'); ?>
<?php if ($_SESSION["dename1"] == 'QC' or $_SESSION["dename1"] == 'IT') { ?>
<? if (isset($_GET['date6'])) {
$date6 = $_GET['date6'];
$date10 = $_GET['date10'];
$serch_t = $_GET['serch_t'];
if ($date6 == '' && $date10 == '' && $serch_t == '') {
$sql = "SELECT *FROM tbcro ";
$result = mysqli_query($conn, $sql);
} else if ($date6 != '' && $date10 != '' && $serch_t == '') {
$sql = "SELECT *FROM tbcro WHERE datecro1 BETWEEN '$date6' and '$date10' ORDER BY datecro ASC";
$result = mysqli_query($conn, $sql);
} else if ($date6 != '' && $date10 != '' && $serch_t != '') {
$sql = "SELECT *FROM tbcro WHERE croid LIKE '%$serch_t%' and datecro1 BETWEEN '$date6' and '$date10'
or membercode LIKE '%$serch_t%' and datecro1 BETWEEN '$date6' and '$date10'
or customername LIKE '%$serch_t%' and datecro1 BETWEEN '$date6' and '$date10'
or sales LIKE '%$serch_t%' and datecro1 BETWEEN '$date6' and '$date10' ORDER BY datecro ASC";
$result = mysqli_query($conn, $sql);
} else if ($date6 == '' && $date10 == '' && $serch_t != '') {
$sql = "SELECT *FROM tbcro WHERE croid LIKE '%$serch_t%'
or membercode LIKE '%$serch_t%'
or customername LIKE '%$serch_t%'
or sales LIKE '%$serch_t%' ORDER BY datecro ASC";
$result = mysqli_query($conn, $sql);
}
?>
<?php
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf([
'default_font' => 'saraban',
'setAutoTopMargin' => 'stretch',
'autoMarginPadding' => 1,
'mode' => 'utf-8',
'format' => 'A4-L'
]);
if ($date6 != '' or $serch_t != '') {
$header = '<table table id="bg-table" width="100%" style=" border-collapse: collapse; margin-top: 0px;" >
<thead>
<tr style="border:0px solid #000; ">
<th colspan="3" style="border-right:0px solid #000; text-align: right;font-size:10pt;" >
<b>
หน้าที่ : {PAGENO} / {nb}
</b>
</th>
</tr>
<tr style="border:0px solid #000; ">
<th colspan="3" style="border-right:0px solid #000; text-align: center;font-size:18pt;" >
<b>
รายงานของคืน
</b>
</th>
</tr>
<tr style="border:0px solid #000; ">
<th colspan="3" style="border-right:0px solid #000; text-align: center;font-size:18pt;" >
<b>
บริษัท โชว์จุ่งลูกหมาก จำกัด
</b>
</th>
</tr>
</thead>
</table>';
$mpdf->SetHTMLHeader($header);
$date = date('Y-m-d H:i:s');
$date = date_create($date);
$date_print = date_format($date, 'วันที่พิมพ์ : d/m/Y เวลา : H:i:s');
$footer = '<table table id="bg-table" width="100%" style=" border-collapse: collapse; margin-top: 0px;">
<thead>
<tr style="border:0px solid #000; ">
<th style="border-right:0px solid #000; text-align: right;font-size:10pt;" >
<b>
' . $date_print . '
</b>
</th>
</tr>
</thead>
</table>';
$mpdf->SetHTMLFooter($footer);
$table_header_3 = '<table style=" border-collapse: collapse; margin-top: 0px;" width="100%">
<thead>
<tr style="border:1px solid #000;padding:4px;">
<th style="border-right:1px solid #000; padding:4px; width=5% text-align: center; font-size:14pt ">No.</th>
<th style="border-right:1px solid #000; padding:4px; width=10% text-align: center; font-size:14pt ">เลขที่ CRO</th>
<th style="border-right:1px solid #000; padding:4px; width=10% text-align: center; font-size:14pt ">วันที่</th>
<th style="border-right:1px solid #000; padding:4px; width=15% text-align: center; font-size:14pt ">ลูกค้า</th>
<th style="border-right:1px solid #000; padding:4px; width=10% text-align: center; font-size:14pt ">รหัสสินค้า</th>
<th style="border-right:1px solid #000; padding:4px; width=5% text-align: center; font-size:14pt ">จำนวน</th>
<th style="border-right:1px solid #000; padding:4px; width=5% text-align: center; font-size:14pt ">หน่วย</th>
<th style="border-right:1px solid #000; padding:4px; width=10% text-align: center; font-size:14pt ">ราคา/หน่วย</th>
<th style="border-right:1px solid #000; padding:4px; width=10% text-align: center; font-size:14pt ">ชื่อเซลล์</th>
<th style="border-right:1px solid #000; padding:4px; width=20% text-align: center; font-size:14pt ">หมายเหตุ</th>
</tr>
</thead>';
$mpdf->WriteHTML($table_header_3);
}
$i = 1;
foreach ($result as $row) {
$aa = $row['croid'];
$sql2 = "SELECT * FROM `tbproadd` WHERE croid = '$aa'";
$result2 = mysqli_query($conn, $sql2);
$table2 = '
<tbody>
<tr style="border:1px solid #000;padding:4px;">
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $i++ . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['croid'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['datecro'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">' . $row['customername'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">' . foreach ($result2 as $row2) { echo $row2['barcode'];} '<br>'. '<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $quantity[0]. '<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $unit[0].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: right; font-size:12pt ">' . $price[0].'<br></td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: center; font-size:12pt ">' . $row['sales'] . '</td>
<td valign="top" style="border-right:1px solid #000; padding:4px; text-align: left; font-size:12pt ">' . $row['remark'] . '</td>
</tr>
</tbody>';
$mpdf->WriteHTML($table2);
}
$closetable = '</table>';
$mpdf->WriteHTML($closetable);
$mpdf->Output();
}
}
?>