Printing image.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nwebhosting
    New Member
    • Oct 2006
    • 23

    #1

    Printing image.

    PHP Version:4.3.9 win32

    Problem: I try to print the image from table dollsimage , gameandtoyname and the pricetype from dolls. (i have 7 images and 7 gameandtoyname) , but This code prints only 3 borders.
    What i am doing wrong? i think the problem is with the $str.
    Pleas help!

    [PHP]
    <?php


    $sql = ("SELECT gameandtoyname, pricetype, dollsimage.imag e_id, dollsimage.imag e_date
    FROM dollsimage, dolls
    WHERE dollsimage.imag e_id = dolls.image_id
    ORDER BY image_date DESC");

    $result = mysql_query ($sql, $conn);

    if (!$result) {
    die('Invalid query: ' . mysql_error());
    }

    $str = "";
    if (mysql_num_rows ($result) > 0)


    {
    while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {

    $i++;
    $image_id = $row["image_id"];
    $gameandtoyname = $row["gameandtoyname "];
    $pricetype = $row["pricetype"];
    $str .="$i. <img border='1' height='90' width='100' src='imagedolls .php?act=view&i id=$image_id$ga meandtoyname$pr icetype'></a> ";

    }
    print $str;
    }



    ?>

    [/PHP]
  • brid
    New Member
    • Oct 2006
    • 13

    #2
    Need a code from script: imagedolls.php.
    Problems in it or wrong parameters for it.

    Comment

    • nwebhosting
      New Member
      • Oct 2006
      • 23

      #3
      Sir here is the imagedolls.php:

      Thanks

      [PHP]
      <?php


      // database connection
      $conn = mysql_connect(" localhost", "root") OR DIE (mysql_error()) ;
      @mysql_select_d b ("products", $conn) OR DIE (mysql_error()) ;
      $sql = "SELECT * FROM dollsimage WHERE image_id=".$_GE T["iid"];
      $result = mysql_query ($sql, $conn);
      if (mysql_num_rows ($result)>0) {
      $row = @mysql_fetch_ar ray ($result);
      $image_type = $row["image_type "];
      $image = $row["image"];
      Header ("Content-type: $image_type");
      print $image;
      }
      ?>

      [/PHP]

      Comment

      • brid
        New Member
        • Oct 2006
        • 13

        #4
        Hm-m, script is clear.
        In your database must be record where field
        image_id=$image _id$gameandtoyn ame$pricetype
        or
        you have mistake in here:
        src='imagedolls .php?act=view&i id=$image_id$ga meandtoyname$pr icetype'
        try correct to:
        src='imagedolls .php?act=view&i id=$image_id'

        Comment

        • nwebhosting
          New Member
          • Oct 2006
          • 23

          #5
          Originally posted by brid
          Hm-m, script is clear.
          In your database must be record where field
          image_id=$image _id$gameandtoyn ame$pricetype
          or
          you have mistake in here:
          src='imagedolls .php?act=view&i id=$image_id$ga meandtoyname$pr icetype'
          try correct to:
          src='imagedolls .php?act=view&i id=$image_id'
          Thanks alot. You did help me.

          Comment

          Working...