Member Avatar for begueradj

Hello people,

I have a problem in displaying my images in the dimensions I wish: I used the following code:

echo'<td><a href="portsdetails.php?idImg='.$idphoto.'"><img src="'.$lien.'" width="10" height="10" border="0"/></a></td>';

Recommended Answers

All 6 Replies

I don't see your issue. Perhaps you could paste the whole html or link to the image?

Member Avatar for begueradj

I don't see your issue. Perhaps you could paste the whole html or link to the image?

Thank you, but I want to resize my image (which name is here: $lien) when displaying it in the dimensions I want. When I put : width="100" height="50" it does not take effect.

Open notepad or textpad and write a PHP code:

<?php

$imagepath="phpimages/dog.jpg";

$image=imagecreatefromjpeg($imagepath);

header('Content-Type: image/jpeg');

imagejpeg($image);

?>

Use above code that is working

Member Avatar for diafol

html should resize. It doesn't actually resize the filesize, just the display, so it will load just as slowly as if it were displaying the actual size. Can't see why

echo "<a href=\"...\"><img src=\"$lien\" width=\"10\" height=\"10\" border=\"0\" /></a>";

doesn't work for you.

<?php

$p = $_GET['p'];
if ($handle = opendir("uploads")) {
	$i = 1;
	while (false !== ($file = readdir($handle))) {
		if ($file != "." && $file != "..") {
			$img[$i] = $file;
			if ($p == $img[$i]) {
				$ci = $i;
			}
			$i++;
		}
	}
	closedir($handle);
	$ti = $i - 1;
	$pi = $ci - 1;
	if ($p == "") {
		$ni = $ci + 2;
	} else {
		$ni = $ci + 1;
	}
	$prevNext = "";
	if ($pi > 0) {
		$piFile = $img[$pi];
		$prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $piFile . "\" title=\"show previous image\"><strong>Previous</strong></a>";
	} else {
		$prevNext .= "<strong>Previous</strong>";
	}
	$prevNext .= " | ";
	if ($ni <= $ti) {
		$niFile = $img[$ni];
		$prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $niFile . "\" title=\"show next image\"><strong>Next</strong></a>";
	} else 
	{
		$prevNext .= "<strong>Next</strong>";
	}
	
	
	if ($p == "") 
	{
		$p = $img[1];
	}
}
?> 


<div class="hRule"></div>

<table border="1" cellpadding="1" cellspacing="1" align="center">
	<tr align="center">
		<td class="nextPrevious"><?php echo $prevNext; ?></td>
	</tr>
	<tr align="center">
		<td> <img src="uploads/<?php echo $p; ?>" border="2"width="400" height="400"></td>
	</tr>
</table>

try this..

Member Avatar for begueradj

html should resize. It doesn't actually resize the filesize, just the display, so it will load just as slowly as if it were displaying the actual size. Can't see why

echo "<a href=\"...\"><img src=\"$lien\" width=\"10\" height=\"10\" border=\"0\" /></a>";

doesn't work for you.

Thank you very much it works thanks to your code:
I replaced echo'....';
by echo "...."; as you wrote it and it really works very fine !!!

Thank you very much again Ardav !

Begueradj

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.