Hello! My First Question

First of all, I’ve been reading the forums for some time and I want to say thanks for the help in advance. It looks like there is a talented group of professionals here.

I know there is another way to do the follow, I’m just not sure how:

[php]@ob_start();

$qstr = ‘’;
$encode = ‘CODE39’;
$bdata = $product->order_product_code;
$height = “20”;
$scale = “2”;
$bgcolor =“FFFFFF”;
$color = “000000”;
$type=“jpg”;

$_POST[‘encode’] = $encode;
$_POST[‘bdata’] = $bdata;
$_POST[‘height’] = $height;
$_POST[‘scale’] = $scale;
$_POST[‘bgcolor’] = $bgcolor;
$_POST[‘color’] = $color;
$_POST[‘type’] = $type;

        foreach($_POST as $key=>$value)

                       $qstr.=$key."=".urlencode($value)."&";
                       echo "<img src='barcode.php?$qstr'>";

                       ob_end_flush();[/php]

Some of the code in here may not even be required. I’m very new to PHP still and I’m trying to modify this to dynamically create bar codes for an online ordering system. Originally, user input via a form was used to set the variables but I know what I want the variables to be already. What I don’t know/don’t understand is how to correctly change the foreach to use the variables I have set. The only one that should be changing is the $bdata variable.

Again, thanks in advance!

–Joel

Hi,

Not sure if I fully understand what you are asking. The code you have shown will display the following assuming that the $product object is set correctly. I have hard coded this to 123123 in the example below. Then as long as there is a barcode.php script in the same folder and this works correctly the image should display.

Try entering the following into your web browser to see if the barcode.php is working properly

barcode.php?encode=CODE39&bdata=123123&height=20&scale=2&bgcolor=FFFFFF&color=000000&type=jpg&

HTH

Ant

Sponsor our Newsletter | Privacy Policy | Terms of Service