Hello,

I have set up a photo gallery and would like to resize the width for each photo displayed! However, I cant seem to get the coding right!

Here is the snippet of code:

//Outputs the image and other data
Echo "<img src=/photos/".$info['photo'] 'width=200' . "> <br>"; 
Echo "<b>Description:</b> ".$info['name'] . "<p> <hr>" ;

As you can see I have tried putting the width =200 in many different ways and before and after the . but it doesnt seem to work. This is the error I get with the current code.

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/cyberwor/public_html/user_photogallery.php on line 85

Does anyone know why I cannot get this to work?

Your help would be gratefully recieved!

Thank you

Justin

echo "<img src='/photos/".$info['photo']."' width='200'><br>"; 
echo "<b>Description:</b> ".$info['name']."<p> <hr>" ;
commented: Very very Helpful! Thankyou :) +1

Thank you
Thank you
Thank you!

May I ask why there is a single ' without an ending one? Where was I going wrong exactly? :/

Your a star so cheers

Justin

May I also ask how would I make it so the photo is a thumbnail of say width 200 then when the photo is clicked on it shows the photo in a large size of say 400 width?

:>/ Im guessing it involves quite alot of coding?

Justin

Im guessing it involves quite alot of coding?

Not really. Do you want the image to expand on the page or do you want a new window to open with the picture in it.?

I am trying to get it so a new page opens.

Its basically so I can tidy up my photo gallery.

So for example .... you would visit the photo gallery page where the photos are listed at a width of say 200pixels.

Then when you click on a photo, it opens up a new page in the same window that is a bigger width of say 450pixels.

Then I want to be able to add a photo comment feature which is why each photo would need a separate page.

Ive been thinking about this and have come up with a possible solution ... I will work at making each photo have its own page then will basically try and create the album page that lists all photos at a smaller size but will try and make the photos links.

Im not sur eif it will work but will give it a go. lol Does this sound the most easier and simple way?

Thanks for all your help guys!

Pass the image variables through the url to the new window. Replace your current code with the following:

<a onclick="window.open('fullview.php?img=<?php echo $info['photo'];?>&amp;name=<?php echo $info['name'];?>','', 'width=500, height=400, location=no, menubar=no, status=no,toolbar=no, scrollbars=no, resizable=no'); return false" style="color:#000000; text-decoration:none; font-size:11px; text-align:center" >
<img src='/photos/<?php echo $info['photo'];?>' width='200'><br>
<b>Description:</b> <?php echo $info['name'];?><p> <hr>
<br />(Click image to enlarge)
</a>

You'll also need to create a page called fullview.php with the following:

<?php
$image=$_GET['img'];
$name=$_GET['name'];
?>
<img src="<?php echo $image;?>" width="450" >
<br>
<?php echo $name;?>

That's it. No need to create a separate page for every picture.

hmm this isnt working because of the < within the {}

How do I get round this?

This is the snippet of code:

<?php
//Retrieves data from MySQL 
$data = mysql_query("SELECT * FROM employees WHERE profile_id = '$members_profiles[username]' ") or die(mysql_error()); 
//Puts it into an array 
while($info = mysql_fetch_array( $data )) 
{ 

<a onclick=\"window.open('fullview.php?img=<?php echo $info['photo'];?>&amp;name=<?php echo $info['name'];?>','', 'width=500, height=400, location=no, menubar=no, status=no,toolbar=no, scrollbars=no, resizable=no'); return false" style="color:#000000; text-decoration:none; font-size:11px; text-align:center\" >
<img src='/photos/<?php echo $info['photo'];?>' width='200'><br>
<b>Description:</b> <?php echo $info['name'];?><p> <hr>
<br />(Click image to enlarge)
</a>

}

I have set the other file up requested. Thank you for your help :D

Justin

$closeHTML
?>

Opps sorry ... didnt close the code off.

<?php
//Retrieves data from MySQL 
$data = mysql_query("SELECT * FROM employees WHERE profile_id = '$members_profiles[username]' ") or die(mysql_error()); 
//Puts it into an array 
while($info = mysql_fetch_array( $data )) 
{ 



<a onclick=\"window.open('fullview.php?img=<?php echo $info['photo'];?>&amp;name=<?php echo $info['name'];?>','', 'width=500, height=400, location=no, menubar=no, status=no,toolbar=no, scrollbars=no, resizable=no'); return false" style="color:#000000; text-decoration:none; font-size:11px; text-align:center\" >
<img src='/photos/<?php echo $info['photo'];?>' width='200'><br>
<b>Description:</b> <?php echo $info['name'];?><p> <hr>
<br />(Click image to enlarge)
</a>



}




$closeHTML
?>

Try:

while($info = mysql_fetch_array( $data ))
{ 
echo"
<a onclick= 'window.open(\"fullview.php?img=".$info['photo']."&amp;name=".$info['name']."\",\"\", \"width=500, height=400,location=no, menubar=no, status=no,toolbar=no, scrollbars=no, resizable=no\"); return false' style=\"color:#000000; text-decoration:none; font-size:11px; text-align:center\" >
<img src='/photos/".$info['photo']."' width='200'><br>
<b>Description:</b>".$info['name']."<p> <hr>
<br />(Click image to enlarge)
</a>";
}

Hmm,

First of all thank you!

Ive just been playing around with this code!

When I put it in it seemed to work by showing the photos but when clicked on the page loaded a 404 Error page saying it couldnt be found.

Also ... what im trying to achieve is that I want the page to load in the same window.

So say there is a list of 10 photos, the person clicks on photo 1 and it opens in the same window and shows the bigger size of the photo. This is where I can then add extra things like a photo comment script, etc! there will be a link where the user can go back to the photo gallery.

I would also like to have it so that the photo gallery displays 2 photos per row and then creates new rows as users add more photos but im just trying to get the thing to work right now,

LOL

justin

A 404 error means that the page isn't where you are pointing in the link. Make sure that fullview.php is in the same directory as the current script on the server. Also, are you referring to the same window as to open in a new tab?

Ah silly me! lol You were right! lol

However, when I click on the photo now it opens up a new window with the red cross box. I checked the properties of the red cross box (which should be the photo) and the file path seems to be correct!

http://www.cyberpetworld.com/members/CIMG0811.JPG

(the photo name for this one is the CIMGO811)

And no ... I wouldnt like the window to open a new tab.

What I mean is if I click on a photo it literally opens the new photo page in the same screen. So it doesnt open any windows or tabs but changes the window that you clicked the photo.

So you only need one window .... that changes when you click the photo.

Thanks again

Ah silly me! lol You were right! lol

However, when I click on the photo now it opens up a new window with the red cross box. I checked the properties of the red cross box (which should be the photo) and the file path seems to be correct!

http://www.cyberpetworld.com/members/CIMG0811.JPG

Your members folder that you are pointing to doesn't even have CIMGO811.jpg, or any other jpg's for that matter. Based on your previous posts code, I think you mean http://www.cyberpetworld.com/photos/CIMG0811.JPG Any time you get a box with a red cross in it, it means you are not pointing to the correct file position in your code. You'll have to learn how to troubleshoot this kind of stuff.

I think this is what you are wanting to do with the image link:

while($info = mysql_fetch_array( $data ))
{ 
echo"
<a href='fullview.php?img=photos/".$info['photo']."&amp;name=".$info['name']."' >
<img src='/photos/".$info['photo']."' width='200'><br>
<b>Description:</b>".$info['name']."<p> <hr>
<br />(Click image to enlarge)
</a>";
}
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.