SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    ?>

  2. #2
    SitePoint Zealot Cute Tink's Avatar
    Join Date
    Apr 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is in postnet2.php? I'm guessing that it does some processing that might be causing the glitch.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Zealot Cute Tink's Avatar
    Join Date
    Apr 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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?

  6. #6
    SitePoint Zealot Cute Tink's Avatar
    Join Date
    Apr 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    how do you create a dynamic page from a dynamic image?

  8. #8
    SitePoint Zealot Cute Tink's Avatar
    Join Date
    Apr 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  9. #9
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    Niche


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •