Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: load into table

  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,045
    Thanks
    10
    Thanked 93 Times in 91 Posts
    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)

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •