duannv2081 2012-07-28 22:38
浏览 40
已采纳

使用PHP显示多个图像

I have this PHP script that returns pictures from the database. I am using a loop now to return 5 pictures at once, but I think they are all overlapping so I am only seeing one. How can I shift each picture a couple of pixels over so I can see the other pictures?

<?php
    $mysqli=mysqli_connect('localhost','root','','draftdb');
    if (!$mysqli)
    die("Can't connect to MySQL: ".mysqli_connect_error());

    $param = isset($_GET['rarity']) ? $_GET['loopcount'] :null;

    $stmt = $mysqli->prepare("SELECT display.PICTURE_ID 
    FROM cards  
    INNER JOIN display ON cards.DISPLAY_ID = display.DISPLAY_ID 
    WHERE display.DISPLAY_ID=? AND cards.CARD_TYPE =?" );

    $cardtype='Rare';


    for ($i=0; $i<=5; $i++) 
    {
      $num[$i] = rand(16,30);
       for ($j=0; $j<$i; $j++) 
       {            
          while ($num[$j] == $num[$i])
          {              
             $num[$i] = rand(16,30);   
          }          

                   $displayid= array_shift($num);   

       }   



    $stmt->bind_param("si", $displayid, $cardtype);
    $stmt->execute();
    $stmt->bind_result($image);
    $stmt->fetch();
    header("Content-Type: image/jpeg");
    echo $image; 
    }


    ?>
  • 写回答

2条回答 默认 最新

  • duanhuo7441 2012-07-28 22:44
    关注

    You can't "display" an image with php. You do that with HTML using the <img> tag. What you do is printing the raw image data and then telling the browser It's a picture. I'm not sure what's gonna happen if you do this and print multiple images, but It's up to the browser how It should handle this probably.

    This is sometimes done with one image if you for example store them as blobs in a database. But not for this purpose of displaying them.

    If you want to merge images you can do this with the GD library in PHP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM