Jump to content

Div Background Not Working??


micahg

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>
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.