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;
}
?>
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.