php - Print Barcode from ID database -
after last barcode question i'm another. barcode script:http://www.shayanderson.com/php/php-barcode-generator-class-code-39.htm works fine static number, or static variable:
$reparationid = uniqid(); // include barcode39 class include "barcode39.php"; // set barcode39 object $barcode = new barcode39("$reparationid"); // display new barcode $barcode->draw();
bu, want $reparationid out of database, last added entry.i tried this, , works without barcode:
$reparationid = "select reparationid reparation order 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"; }
as asked, reparationid shown number, works. wanted merge 2 scripts, point goes wrong. doesn't work @ all. tried this:
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"; }
there blue question mark, nothing more.. ideas?
thanks,
br, daan
tip: don't include
whilst in while
loop, move above loop.
change line become;
$barcode = new barcode39($row["reparationid"]);
$reparationid
doesn't exist in script you've given, , if does; doesn't have value fetched database. (it have value of database query string though)
Comments
Post a Comment