Jump to content


Div Background Not Working??

  • Please log in to reply
1 reply to this topic

#1 micahg

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 28 June 2006 - 02:20 AM

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:

//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 } ?>

#2 SharkBait

  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 29 June 2006 - 01:52 PM

This line:
 <?PHP print("<div class=\"test\" style=\"background:url($thumbnail_dir$photos[$i]~.jpg)\">

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

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users