Welcome Guest, Not a member yet? Register   Sign In
Generate 2 thumbnails & Insert File Names into Database?
#11

[eluser]invision[/eluser]
Cool!

So if I was to generate code like the following, how would I achieve this?

Would I have to use 'breaks' to add in the style="margin-left:6px;" and the break tag.

Code:
<a href="[removed]showPicture('1.jpg', '');"><img src="1-small.jpg" /></a>
<a href="[removed]showPicture('2.jpg', '');"><img src="2-small.jpg" style="margin-left:6px;" /></a>
<a href="[removed]showPicture('3.jpg', '');"><img src="3-small.jpg" style="margin-left:6px;" /></a><br />
<a href="[removed]showPicture('4.jpg', '');"><img src="4-small.jpg" style="padding-top:6px" /></a>
<a href="[removed]showPicture('5.jpg', '');"><img src="5-small.jpg" style="margin-left:6px;padding-top:6px" /></a>
<a href="[removed]showPicture('6.jpg', '');"><img src="6-small.jpg" style="margin-left:6px;padding-top:6px" /></a>
#12

[eluser]Narkboy[/eluser]
[quote author="invision" date="1295971031"]Cool!

So if I was to generate code like the following, how would I achieve this?

Would I have to use 'breaks' to add in the style="margin-left:6px;" and the break tag.

Code:
<a href="[removed]showPicture('1.jpg', '');"><img src="1-small.jpg" /></a>
<a href="[removed]showPicture('2.jpg', '');"><img src="2-small.jpg" style="margin-left:6px;" /></a>
<a href="[removed]showPicture('3.jpg', '');"><img src="3-small.jpg" style="margin-left:6px;" /></a><br />
<a href="[removed]showPicture('4.jpg', '');"><img src="4-small.jpg" style="padding-top:6px" /></a>
<a href="[removed]showPicture('5.jpg', '');"><img src="5-small.jpg" style="margin-left:6px;padding-top:6px" /></a>
<a href="[removed]showPicture('6.jpg', '');"><img src="6-small.jpg" style="margin-left:6px;padding-top:6px" /></a>
[/quote]

Um...

If you loop an array then you can specify output for all items, odd and even items or any other mathematically definable series. I can't see one in your short sample!

I would suggest that you define a common style for all images - something like:

Code:
img.thumb {
    margin: 3px;
    padding: 3px;
}

Otherwise you'll need to spend time explaining to either PHP or to HTML / CSS how to work out which images need which styles.

Keep it simple!

/B

EDIT:

If you've only ever got a small number of images at a time, then you could use a PHP switch block to append the style text to the echo statement within the loop, but you'll need a for loop rather than foreach so that you can test the array offset.
#13

[eluser]invision[/eluser]
Good call.

"Keep it simple!" is so true. Will work on this tonight. Wish me luck Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB