Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-18-2004, 11:48 PM   PM User | #1
britishrallying
New to the CF scene

 
Join Date: Mar 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
britishrallying is an unknown quantity at this point
load into table

Hi,

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

PHP Code:
<table width="750" height="600" <?php include "images.php"?>>
I need to load this into my main table as a background:
PHP Code:
<?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 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
britishrallying is offline   Reply With Quote
Old 03-19-2004, 08:26 AM   PM User | #2
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,911
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
just change the HTML in your image.php (there are other ways but this is the quickest fix)

PHP Code:
<?php
echo "background=\"$directory$image[$randNum]\""
?>
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 03-19-2004, 11:09 AM   PM User | #3
britishrallying
New to the CF scene

 
Join Date: Mar 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
britishrallying is an unknown quantity at this point
Nice one firepages.

It Works

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!!
PHP Code:
<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?
PHP Code:
document.getElementById('main').style.background="white url("+img.src+") no-repeat fixed top" 
Thanks,

Gareth
britishrallying is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:10 AM.


Advertisement
Log in to turn off these ads.