Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Image Gallery (and thumbnails) help
Old 07-25-2004, 07:39 PM Image Gallery (and thumbnails) help
Experienced Talker

Posts: 35
Trades: 0
Hi,

I'm looking for some code to use on a gallery page. In a database, I have some data stored such as the article ID for the images, eg. "2607041" and there is also a number such as "19" which is the total number of images available.

Basically, I'd like to retrieve that number and use it to return 19 thumbnail images, incrementing for each. So the 1st thumbnail would be 001.jpg, the second 002.jpg up to the 19th thumbnail as 019.jpg.

Also, the table where the images are show would need to have no more than 5 images on each row and if the total number of images exceeds 25, I'd need a link to the next page, where it would start the thumbnails from no. 26. Then that would need a previous button etc.

Do you know what I mean?

If you can help, I'd much appreciate it.

Sam
Sam Stockley is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-25-2004, 08:41 PM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
This was discussed many times at this forum. Simple add the zerro before your numbers. And in sql request use LIMIT 0,25 next will be LIMIT 25,25.
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-26-2004, 04:41 AM
Experienced Talker

Posts: 35
Trades: 0
That's not the big problem. The thing I don't have a clue to do is how to create 19 thumbnails with 5 on each row. Any ideas?
Sam Stockley is offline
Reply With Quote
View Public Profile
 
Old 07-26-2004, 08:54 AM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
Thats simple
PHP Code:
$limit=5;
$files=19;
$cell=1;
echo 
"<table><tr>";
for(
$i=1$i<=$files$i++){
echo 
"<td><img src='yourimg'></td>";
if(
$cell!=$limit) {
$cell=$cell+1;
}else{
echo 
"</tr><tr>";
$cell=1;
}
}
echo 
"</tr></table>" 
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-26-2004, 07:36 PM
Experienced Talker

Posts: 35
Trades: 0
Wow! That works great! Thanks.

Only thing is, it only returns the same image for each thumbnail. How can I make it return 001.jpg for thumbnail #1, 002.jpg for #2 etc. up to #19 for 019.jpg (keeping zero).

Thanks.
Sam Stockley is offline
Reply With Quote
View Public Profile
 
Old 07-26-2004, 09:58 PM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
Have fun

PHP Code:
$limit=5
$files=19
$cell=1
echo 
"<table><tr>"
for(
$i=1$i<=$files$i++){ 
if (
$i 10) { $num "00".$i
} else if(
$i 100) {
 
$num "0".$i
}
echo 
"<td><img src='".$num.".jpg'></td>"
if(
$cell!=$limit) { 
$cell=$cell+1
}else{ 
echo 
"</tr><tr>"
$cell=1


echo 
"</tr></table>" 
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-

Last edited by Veter; 07-26-2004 at 10:00 PM..
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-27-2004, 07:55 PM
Experienced Talker

Posts: 35
Trades: 0
Thanks Veter. That worked great! All I need to do now is integrate it with my pages and add a popup window javascript.

Your help is much appreciated.

Sam
Sam Stockley is offline
Reply With Quote
View Public Profile
 
Old 07-27-2004, 08:32 PM
Experienced Talker

Posts: 35
Trades: 0
The auto-generation of thumbnails works almost perfectly. The first row always seems to return 6 thumbnails despite being limited to 5. Any ideas?

Secondly, for some odd reason, my javascript window is ignoring 'status=yes,width=484,height=464' and opening a default window size with no status bar. I'm sure it has something to do with my placing of quotes but I've had quite a fiddle and had no luck. Anyone know what I'm doing wrong? The window launches fine it is just that the status and dimensions remain undefined.

PHP Code:
<?
$limit
=5
$files=$gallery_total
echo 
"<table><tr>"
for(
$i=1$i<=$files$i++){ 
if (
$i 10) { $num "00".$i
} else if(
$i 100) { 
$num "0".$i

echo 
"<td><a href='javascript:'><img src='../images/thumb/".$fullid."/".$fullid."_".$num."th.jpg' alt='Click here to view larger image' width='80' height='80' border='1' onClick=\"MM_openBrWindow('../images/view-standard.php?id=".$fullid."&image=".$num."','".$fullid."".$num."','".$fullid."".$num."','status=yes,width=484,height=464')\"'></a></td>";
if(
$cell!=$limit) { 
$cell=$cell+1
}else{ 
echo 
"</tr><tr>"
$cell=1


echo 
"</tr></table>" 
?>
Thanks
Sam Stockley is offline
Reply With Quote
View Public Profile
 
Old 07-27-2004, 08:58 PM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
Put $cell=1; right after $limit=5;

And try to put all options 'scrollbars=yes,toolbar=no,status=no,resizable=yes ,width=484,height=464'
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-29-2004, 09:32 AM
Experienced Talker

Posts: 35
Trades: 0
Thanks, Veter.

The $cell=1 seemed to fix that but the javascript popup is still a problem. You can look at the offending page below.

The site is password protected whilst development is going on:

http://www.thecarfanatics.com/sam/ne...php?id=1407041

User: webtalk
Pass: opensesame

Click "Related Gallery" to see the problem here.

Last edited by Sam Stockley; 07-29-2004 at 09:35 AM..
Sam Stockley is offline
Reply With Quote
View Public Profile
 
Old 07-29-2004, 03:42 PM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
Oh yes
Look here:
Quote:
('../images/view-standard.php?id=3003041&image=001','3003041001','3 003041001','scrollbars=yes,toolbar=no,status=no,re sizable=yes,width=484,height=464')
You have one extra '3003041001', in the function call. remove it and it will be fine.

Nice site btw.

Few advices:
Take out CSS in standalone file and do the same with java sript functions
__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-29-2004, 06:41 PM
Experienced Talker

Posts: 35
Trades: 0
Thank you VERY much, Veter. Not sure how I managed to add two in.

Thanks for the comment about the site. Much appreciated.

The CSS is included via PHP as a .css file - is that what you mean?
Sam Stockley is offline
Reply With Quote
View Public Profile
 
Old 07-29-2004, 07:10 PM
Veter's Avatar
Super Talker

Posts: 147
Trades: 0
I mean all your stuff from <style type="text/css"> ... </style> section take out to the other file, called style.css.
And instead of the <style type="text/css"> ... </style> section
just put <link href="style.css" rel="stylesheet" type="text/css">

__________________
-=
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
=-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Reply     « Reply to Image Gallery (and thumbnails) help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.59452 seconds with 12 queries