Script only displays last item in a selection

I have a script that supposed to display the barcode for each item in the selection (66 rows in this case). However, it displays the barcode from the last item 66 times.

How do I display each item selected? I know all the result of the mysql selection is complete.

Here’s the script:

<?php
require('class/BCGFont.php');
require('class/BCGColor.php');
require('class/BCGDrawing.php');
require('class/BCGpostnet.barcode.php');

require_once "connect_to_mysql.php";
$result = mysql_query("SELECT * FROM maillist WHERE LEFT(zip,5) = '68502'") or die(mysql_error());

while ($row = mysql_fetch_array($result)) {
$zip11 = $row['postnet ip'];
include "postnet2.php";
echo '<img src="postnet.png" alt="some_text" > <br/>';
}
?>

This script produces the same problem except it displays the fourth item selected four times:

<?php
require('class/BCGFont.php');
require('class/BCGColor.php');
require('class/BCGDrawing.php');
require('class/BCGpostnet.barcode.php');

require_once "connect_to_mysql.php";
$result = mysql_query("SELECT * FROM maillist WHERE LEFT(zip,5) = '68502'") or die(mysql_error());

$row = mysql_fetch_array($result);
$zip11 = $row['postnet ip'];
include "postnet2.php";
echo '<img src="postnet.png" alt="some_text" > <br/>';

$row = mysql_fetch_array($result);
$zip11 = $row['postnet ip'];
include "postnet2.php";
echo '<img src="postnet.png" alt="some_text" > <br/>';

$row = mysql_fetch_array($result);
$zip11 = $row['postnet ip'];
include "postnet2.php";
echo '<img src="postnet.png" alt="some_text" > <br/>';

$row = mysql_fetch_array($result);
$zip11 = $row['postnet ip'];
include "postnet2.php";
echo '<img src="postnet.png" alt="some_text" > <br/>';

?>

What is in postnet2.php? I’m guessing that it does some processing that might be causing the glitch.

That script is fine, but by the time the browser gets the HTML code and asks for the image it’s going to be set to whatever the last one was.

So, <img src=“postnet.png” alt=“some_text” > is the problem? I can suggest then that you, perhaps, come up with unique names for the image, because, yes, the image is going to be the same if you are passing the same name for all of the images.

That’s the approach I switched to and it works. Though, it’s hard to believe dynamic images aren’t working. Any thoughts as to why?

When I’ve needed dynamic images in the past, I’ve created them as php pages and passed the variables to the page to be created. A single page can create multiple different images in that case and they are different to the HTML. I’m guessing that the HTML isn’t seeing it as a dynamic image and the last image created with that name is the one that is being displayed because of that.

how do you create a dynamic page from a dynamic image?

Actually you create a dynamic image with a dynamic page.

PHP: imagecreate - Manual

If that is beyond your needs, it might be best to create a series of images and store them for use with each item. Are these images you have changing all the time or could they be associated with particular records?

Thanks,

Niche