Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hello,
    In my php script I would like to have an image background in one of the tables replacing a white background:

    ".print_dats_stg()."
    <table width='600px' bgcolor='#FFFFFF' border=0 cellspacing=0 cellpadding=0>

    How can I replace that bgcolor code to have my bg picture from the "pics" folder?
    Thank you very much for help.

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    First of all, it's always better to use CSS, so it would be a <div> background.

    But for a table ...
    <table cellpadding='0' cellspacing='0' style='background-image:url(./pics/myphoto.jpg);'>

    ... and I don't know if you need to specify height and width also (experiment with that).

    With a PHP script, you would have a variable, sort of like this ...

    $myphoto="./pics/myphoto.jpg";
    echo"<table cellpadding='0' cellspacing='0' style='background-image:url($myphoto);'>";


  4. #3
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Thank you very much for your tip, it works! :-)

    Could I also ask one more question:
    In php script if I want to use font size exactly the same as in html (12px, 14px, 22px, etc) how am I supposed to code the demand? This sample is not working, it displays huge letters:

    <font FACE='ARIAL' size='13px' color='#000000'>

  5. #4
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Scrap the font tag. Get up to date with CSS!
    Code:
    <span style="font-family: Arial; font-size: 13px; color: #000;"></span>
    Note that in standard-compliant browsers, using px will still scale according to text size (in the view menu).

    And btw this has nothing to do with PHP.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  6. #5
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hi Steax,
    Thanks for message.
    I would like to use .css more often, but my biggest problem is "How to?" within php scripts. It is very easy to put in a header of html document a link to external css file. Where to put it when I have 2000 lines of code, with so many table-s, td-s, tr-s...

    Please tell me what it is btw? (I'm french speaking person)

  7. #6
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Ok let me clear it out for you.

    HTML will control your page's content. It always will, but sometimes people (mis)use it for layout, with tables. Try avoiding this when possible.

    PHP will control your page's content by request. It will take requests from all sorts of places, process them, and ultimately inject them into your HTML or do other processing, like modifying a database.

    CSS will control your page's display. From font sizes to layout. Well it should. CSS applies itself through selectors - elements, IDs, Classes, or inline CSS. Simply said, if you apply some CSS rules into the selector "#something", browsers will look for any element in the HTML with "id="something". The # is to mean ID, use a period for classes ( .myclass looks for an element with class="myclass"), and just state the name of the element for element selectors ( h1 will look for the <h1> tag). That element's contents (everything within that element's opening tag and closing tag) will be modified according to the rules in the CSS.

    This means if you want to change settings for, say for the <body> element, you can do:
    Code:
    body{
      color: #f00;
    }
    This makes all text within the body red, if it's not defined by a more specific selector (this can go pretty deep, and this is just a crash explanation).

    In your case, you will want the line to have specific font rules. To do this, we use the dummy tag <span>. This applies the rules assossiated with it into everything between its opening and closing tag. You can use <div> too, for block-level elements. Try it.

    Now, in the answer above I gave an inline CSS. This can be done on any element and can be specified from the HTML itself, not a CSS file. It's advisable to do this only when the CSS will be applied in that specific location. It's simply a style="color:#f00" property inside any tag.

    There are lots and lots of CSS rules. Font-family for font faces, background for, well, backgrounds with a whole load of effects (like tiling, etc). There are also pseudo-selectors, like a:hover{} will apply itself to all <a> tags when the cursor is hovering over them.

    XHTML doesn't like using "display tags", which are tags that have no real meaning except to customize display. This includes <b>, <i>, and <font>, because HTML is supposed to be just an organized form of content, that CSS will control for display. Things like <h1> or <p> are fine because they mean something ("this is an important heading" and "this is a paragraph").

    That's that for my crash course.

    And if you happen to already understand CSS good enough, then just remember to wrap any content you want to change with the CSS selector containing the rules.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  8. #7
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hello
    Steax thank you very much for your explanation, you are A Star!!!

    Could you please help me with this one.
    In my php script there are a lot of tables (like the one below) some of which I would like to put in a bigger one: 90% width, bgcolor black. I tried to apply <table> tag just after <centre> tag (and </table> before </centre>). Although the script is showing up OK (no error message) the large, black table is not showing at all in the design. How could I make it working?


    echo"
    <center>
    #in my trial the large table starts here < table width='90%' bgcolor='#000000' >
    <table width='450' >
    <tr><td>
    <font FACE='ARIAL, HELVETICA' size='-1'>
    <b><a href='adtbl.php'>Top:</b>
    </font>
    </td></tr></table>
    <table width='450' bgcolor='#dddddd'>
    <tr><td>
    <center>
    <font FACE='ARIAL, HELVETICA'>
    <b>Browsing $mode_text</b>
    </font>
    #in my trial the large table ends here < /table>
    </center>
    </td></tr></table>
    ";


    PS
    Sorry for colours, in my script everytig is dark red.

  9. #8
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Use the [ code ] tags in these forums to display code in a box like I did above.

    That script is highly out-of date... Lets go over it.

    First you want a big table that stretches to 90%. Instead of tables, use a <div> with CSS, as such:
    Code:
    <div style="width: 90%; background: #000">
    Remember to escape the quotes (by turning all quotes into a \" - put a backslash in front of them) so the echo() will work properly.

    Then a bunch of single-row tables... replace those with divs too.

    Tip: If you want to apply a CSS rule to the entire page, just hook it on to the body element. So you don't need to declare your fonts over and over. As for centering text, use the CSS rule "text-align: center;"
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  10. #9
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    pierrot,

    It sounds like you might be customizing an older script that is using <tables>?

    Let us know if that's what is happening. We're pressing the CSS issue, but you
    may be stuck with what you have, in that case, you'll keep the <tables> and
    we can work around it.

    With <table> background colors, you'll actually be changing the <td> background ...
    Like this: <td bgcolor="#000000">

    That's why you don't see the black background.


  11. #10
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    I figured he might be customizing an old script... but in the instance above (using singe-cell tables) it's totally unecessary.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com