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 (postnet.php

<?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/>';

?>

Recommended Answers

All 2 Replies

1) why you are hard coding '68502' in your query. You must pass some get/post variable for getting the dynamic content.
2) $zip11 = $row; // YOu are fethcing things in zip11 but then you are not making use of it, why?

Also explain your problem little bit more and attach all used php files and mysql table structure.

You must filter your select query based on selection.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.