마지막 바코드 질문 후 다른 답변으로 돌아 왔습니다. 이 바코드 스크립트 : http://www.shayanderson.com/php/php-barcode-generator-class-code-39.htm 정적 번호 또는 정적 변수와 함께 잘 작동 :ID 데이터베이스의 바코드 인쇄
$reparationid = uniqid();
// include Barcode39 class
include "Barcode39.php";
// set Barcode39 object
$barcode = new Barcode39("$reparationid");
// display new barcode
$barcode->draw();
니어, 난 데이터베이스 밖으로 $ reparationID을 원하는이, 마지막에 추가 entry.i이 시도하고 바코드없이 작동 :
$reparationid = "SELECT reparationid FROM reparation ORDER BY added DESC LIMIT 1";
$result = $link->query($reparationid);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
print($row ["reparationid"]);
}
}
else {
echo "0 results";
}
질문 : reparationid가 숫자로 표시되어 작동합니다. 이제 저는이 두 개의 스크립트를 병합하고 싶었습니다. 그러나 그것이 잘못되는 지점입니다. 그것은 전혀 작동하지 않습니다. 나는이 시도 :
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
print($row ["reparatieid"]);
// include Barcode39 class
include "Barcode39.php";
// set Barcode39 object
$barcode = new Barcode39("$reparationid");
// display new barcode
$barcode->draw();
}
}
else {
echo "0 results";
}
파란색 물음표, 아무것도 더 .. 어떤 아이디어가있다?
감사합니다,
브롬, Daan
print ($ row [ "reparatieid"]); - 두 번째 병합 된 코드에서 대신 $ reparationid = $ row [ "reparationid"] –
** 팁 : ** while 루프에 'include'하지 마십시오. 루프 위로 이동하십시오. –
이것은 실제로 바코드 생성기와 관련이 없습니다. 그것은 간단한 PHP 구문 질문입니다. 어쩌면 당신은 한 걸음 뒤로 물러나고 [변수에 대해 읽으십시오] (http://php.net/manual/language.variables.php). – Yoshi