...

View Full Version : load into table



britishrallying
03-19-2004, 12:48 AM
Hi,

Sorry im new to .php, but is it possible to load say a background image to a table id?


<table width="750" height="600" <?php include "images.php"; ?>>I need to load this into my main table as a background:
<?php
$dir=opendir("images/bg/color/");
//This is the directory route to the folder
$directory="/images/bg/color/";
//This is a relative link to the directory if it is not in the same directory as the file you are displaying the images on

$pattern="\.(gif|jpg|jpeg|png|bmp|swf)$";
if(!$dir)
{
die("Failed to read directory");
}
$s=readdir($dir);
$count="0";
$image;
while($s)
{
if(ereg($pattern, $s))
{
$image[$count]=$s;
$count++;
}
$s=readdir($dir);
}
closedir($dir);

//Spit it out
$limit=count($image);
$limit--;
$randNum=rand(0,$limit);
echo "<br><img src=\"$directory$image[$randNum]\" $size[3]>";
?>I have come up with this Test Page (http://www.britishrallying.com/test.php) but i need it to be embedded into the table. Ive put <?php include "images.php"; ?> between the <td> </td>tags

Think I have confused my self again!:)

Thanks in advance,

Gareth

firepages
03-19-2004, 09:26 AM
just change the HTML in your image.php (there are other ways but this is the quickest fix)



<?php
echo "background=\"$directory$image[$randNum]\"";
?>

britishrallying
03-19-2004, 12:09 PM
Nice one firepages.

It Works (http://www.britishrallying.com/test1.php)

I've called it into the table as below, is this the right way of doing it, i shouldnt really say anything as it works!!:)
<table <?php include "images.php"; ?> width="750" height="600" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#006bad" id="Main">I was wondering if there was away like with javascript you call php to say the id of a table?
document.getElementById('main').style.background="white url("+img.src+") no-repeat fixed top"Thanks,

Gareth



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum