hey guys, how can i show images by php? i mean image; <img src="http://www.site.com/img/324.jpg" /> Code (markup): i want to use it like; <img src="http://www.site.com/image.php?id=324" /> Code (markup): what's the image.php? <?php $id = intval($_GET['id']); header('Content-Type: image/jpeg'); // i couldn't do after this line "http://www.site.com/img/".$id.".jpg"; // ?? ?> Code (markup):
Try this: $id = intval($_GET['id']); $the_image_file = "/img/".$id.".jpg"; $image = imagecreatefromjpeg($the_image_file); header('Content-type: image/jpeg'); imagejpeg($image); imagedestroy($image); Code (markup):
Any html can be displayed in the browser by using echo or print. Like <?php $id = intval($_GET['id']); echo "<img src='http://www.site.com/img/".$id.".jpg'>" ?> or <?php $id = intval($_GET['id']); print "<img src='http://www.site.com/img/".$id.".jpg'>" ?>
Though I am not sure but I think you're lacking a closing quotation mark and a semi-colon on this line:
On the last line before php closing tags, its not needed to put semi-colon after the code. Refer http://php.net/manual/en/language.basic-syntax.instruction-separation.php
Oops! The Guy is talking about showing an image using a Dynamic PHP Page template BTW: The Thread Starter imgae.php must look like <?php $id = intval($_GET['id']); header('Content-Type: image/jpeg'); // i couldn't do after this line ?> <html><head></head><body> <img src="http://www.site.com/img/<?php echo $id; ?>.jpg" /> <body></html> ?> PHP: