Jump to content

Archived

This topic is now archived and is closed to further replies.

micahg

Div Background Not Working??

Recommended Posts

Okay so it would be great if i could get this working properly. I have a little gallery script here that produced using a tutorial i found online. I modified it slightly and it works fine when i use tables. Now iam trying to switch to DIV's and have it place the thumbnail as the background image instead of having it place the thumbnails in a table with cells. It outputs all the correct HTML when you view the source so i have no idea what is going on.
Any advice would be greatly appreciated. Here is a link to the page that i have been testing it on. [a href=\"http://www.micahg.com/art/arttest.php\" target=\"_blank\"]http://www.micahg.com/art/arttest.php[/a] and here is my php:

<?PHP
//initialize variables
$data_file = "list.photos";
$thumbnail_dir = "thumbs/";
$photos = file($data_file);
$total_photos = sizeof($photos);

$i = 0;
?>
<div style="display:block; width:250px; height:300px;">
<?PHP for($i=0; $i < $total_photos; $i+=2) { ?>
<?PHP print("<div class=\"test\" style=\"background:url($thumbnail_dir$photos[$i]~.jpg)\">
<a href=\"javascript:photo_open('photo_display.php?start=".$i."','750','715');\"><img src\"../images/spacer.gif\" width=\"40\" height=\"40\"></a></div>\n"); ?>

<?PHP } ?>
</div>

Share this post


Link to post
Share on other sites
This line:
[code]
<?PHP print("<div class=\"test\" style=\"background:url($thumbnail_dir$photos[$i]~.jpg)\">
[/code]

Should it not read:
[code]
<?php
print("<div class=\"test\" style=\"background-image: url('{$thumbnail_dir}{$photos[$i]}~.jpg')\">
[/code]

I'm unsure about the ~ (tilde) mark but the rest should work as long as the thumbnail is in
thumbs/nameofphoto.jpg

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.