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 12 of 12
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts

    td width style in php script not working

    Hi

    I can not see why this shouldn't work:

    PHP Code:
    echo "
    <tr style=\"color: $colr; font-size:12px;\">
        <td>$offer_id</td>
        <td>$create_date</td>
        <td>$ofcatcd</td>
        <td>$prod_no</td>
        <td><a href=\"$link1\">$ad_title</a></td>
        <td style=\"width:100px;\">$ad_text</td>
        <td>$ad_website</td>
        <td>$ad_link</td>
        <td>$views</td>
        <td>$clicks</td>
    </tr>"


    The $ad_text record can be up to 400 characters so I want it
    to be a restricted width and wrap so the table stays with the page.

    Have I done something wrong here

    Thanks




    .
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #2
    New Coder
    Join Date
    Jul 2009
    Location
    UK
    Posts
    89
    Thanks
    5
    Thanked 11 Times in 11 Posts
    How does it display currently?
    Last edited by jswany; 10-10-2013 at 03:21 PM. Reason: miss read the users question so removed a question I asked
    I'd love to change the world, but they wont give me the source code.

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Like this:

    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This hasn't a thing to do with PHP. Moving to HTML/CSS forum.
    Works for me in FF, not sure of the standards.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,451
    Thanks
    17
    Thanked 275 Times in 275 Posts
    Quote Originally Posted by jeddi View Post
    Like this:

    Showing the image of the page is nice, but please show us the source of the rendered page too ! To style it, you may be better assigning it a class and styling that class in the .css.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #6
    New Coder
    Join Date
    Jul 2009
    Location
    UK
    Posts
    89
    Thanks
    5
    Thanked 11 Times in 11 Posts
    It works for me in Firefox and IE,

    though I'm not brilliant with CSS but you could try specifying word wrap that's what I would do if it wasn't working.

    PHP Code:
    echo "
    <tr style=\"color: $colr; font-size:12px;\">
        <td>$offer_id</td>
        <td>$create_date</td>
        <td>$ofcatcd</td>
        <td>$prod_no</td>
        <td><a href=\"$link1\">$ad_title</a></td>
        <td style=\"width:100px; word-wrap:normal;\">$ad_text</td>
        <td>$ad_website</td>
        <td>$ad_link</td>
        <td>$views</td>
        <td>$clicks</td>
    </tr>"

    I'd love to change the world, but they wont give me the source code.

  • #7
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Hi,
    Thanks for the replies.

    I tried using Firefox to view it and got same result.

    Here is the source code from FF

    Code:
    <table>
    	<caption>Products Listings</caption>
    	<tr style="font-size:14px;">
    		<th>Id.</th>
    		<th>Owner</th>
    		<th>Type</th>
    		<th>Directory</th>
    		<th>Title</th>
    		<th>Text</th>
    		<th>Website</th>
    		<th>Price</th>
    		<th>Old Price</th>
    	</tr>
    	<tr style="color: green; font-size:12px;">
    		<td>1</td>
    		<td>3</td>
    		<td>1</td>
    		<td>30daybum</td>
    		<td><a href="write_prod.php?a=1">30 Day Bum Marketing</a></td>
    		<td style="width:200px; word-wrap:normal;">Price Slashed from 17.99 to 1.75 of this Software and Action PDF. Learn how to generate income using a systemized approach to article marketing. Takes you step by step through the process and provides you with a schedule to follow. Now only $1.75</td>
    		<td>30-Day-BUM-Mkg</td>
    		<td>175</td>
    		<td>1799</td>
    		</tr>
    </table>
    The screen result is same as the image I show

    I must a-have got something wrong

    Thanks.



    .
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #8
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,451
    Thanks
    17
    Thanked 275 Times in 275 Posts
    It works for me in Firefox, Chrome and Opera. It even works if I apply the width property to the corresponding th, the tds take on its width. You may have other styling on the page which interferes with it.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #9
    New Coder
    Join Date
    Jul 2009
    Location
    UK
    Posts
    89
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Yep, it works for me in all common browsers too. What other CSS is used, maybe you could post it and I'll have a look to see if anything else interferes with it like DrDOS said.
    I'd love to change the world, but they wont give me the source code.

  • #10
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    OK - that's interesting.

    I will look at the css for the td's - but since I am applying
    inline style - as it is the last to be applied - and therefore
    it should over-ride any other css - shouldn't it ?

    I will apply the same inline style to the heading as well.

    Thanks very much for looking.

    I just "inspected the element" and here
    is the css inherited:
    Code:
    element.style {
    width: 200px;
    word-wrap: normal;
    }
    
    td, th {
    border-bottom: 1px solid #333333;
    padding: 6px 16px;
    text-align: left;
    }
    
    * {
    margin: 0;
    padding: 0;
    }
    
    user agent stylesheettd, th {
    display: table-cell;
    vertical-align: inherit;
    }
    
    Inherited from tr
    Style Attribute {
    color: green;
    font-size: 12px;
    }
    
    Inherited from table
    table {
    white-space: nowrap;
    border-collapse: collapse;
    }
    
    user agent stylesheettable {
    border-collapse: separate;
    border-spacing: 2px;
    border-color: gray;
    }
    
    Inherited from div.in_box
    .in_box {
    text-align: left;
    }
    
    Inherited from div.asset_box
    .asset_box {
    color: maroon;
    font-size: 22px;
    line-height: 40px;
    text-align: left;
    }
    
    Inherited from html
    html {
    font-family: Helvetica,Arial,sans-serif;
    }
    Does that show the problem ??

    Thanks.



    .
    Last edited by jeddi; 10-11-2013 at 08:27 AM.
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #11
    New Coder
    Join Date
    Jul 2009
    Location
    UK
    Posts
    89
    Thanks
    5
    Thanked 11 Times in 11 Posts
    So I made a test page using your table and applied the CSS to it and I get the same results as you. I then went through commenting out sections of the CSS. It seems it is the white-space:nowrap; that is causing the issue. I would have thought the same as you, that the inline style would override this. Though I think this isn't happening as the nowrap is applied to the <table> and your inline CSS is applied to <TD>.
    Code:
    table {
    white-space: nowrap;
    border-collapse: collapse;
    }
    To clarify it works when I remove the white-space:nowrap; but doesn't if I leave it there.

    You could try using pre-wrap instead of no-wrap which seems to work.
    nowrap: Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br /> tag is encountered
    pre-wrap: Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks
    Alternatively you could apply an inline style to your table to override it which also works.
    Code:
    <table style="white-space: normal;">
    Last edited by jswany; 10-11-2013 at 10:12 AM.
    I'd love to change the world, but they wont give me the source code.

  • Users who have thanked jswany for this post:

    jeddi (10-11-2013)

  • #12
    Senior Coder
    Join Date
    May 2006
    Posts
    1,683
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Great
    Took out that line "white-space:nowrap;"

    And now it works

    Hopefully it won't mess anything up - but will see

    Thanks again.


    .
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.


  •  

    Posting Permissions

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