www.webdeveloper.com
Results 1 to 6 of 6

Thread: <table> Problems with bordercolor/border.

  1. #1
    Join Date
    Nov 2013
    Posts
    3

    <table> Problems with bordercolor/border.

    Hello all.

    I got a problem. When i define
    Code:
    <table bgcolor=D8D8D8 border=4 bordercolor=A4A4A4 WIDTH=515px>
    then all my <td> and <tr> gets the border and color. Even if i try to define
    Code:
    <td border=0 bordercolor=D8D8D8 COLSPAN=5></td>
    Here is the code. I cant use CSS cause im using "echo" something. I not 100% sure why CSS is not accepted.

    Code:
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result)) {
    
    echo" 
    <table bgcolor=D8D8D8 border=4 bordercolor=A4A4A4 WIDTH=515px> 
    	<td border=0 COLSPAN=5 bgcolor=A4A4A4 width=340px><b>&nbsp "; echo $row['_arrangement'] . " </b></td> 
    	<tr>
    		<td border=0 bordercolor=D8D8D8 COLSPAN=5>"  . $row['_beskrivelse'] . " </td>	
    	</tr>
    	<tr>
    		<td border=0 width=70px height=15px> <b>Adresse:</b></td>
    			<td COLSPAN=2> "  .  $row['_adresse'] .  " </td>
    				<td width=10px ROWSPAN=2> "; printf('<a href="http://%s" target="_blank"><img src="images/asd.png" BORDER=0 width="41" height="41" /></a>', $row['_link']); echo "</td>
    					<td></td>
    	</tr>	
    	<tr>
    		<td><b>Link:</b></td> <td COLSPAN=2> " . "<a href=http://".$row['_link'] ." target=_blank>" .$row['_link'] . " </a></td>
    	</tr>
    	<tr>
    		<td  COLSPAN=2>" . "<img src=image.php?_nr=".$row['_nr']. " width=300 height=168/>" . "</td>
    			<td width=20px  COLSPAN=3>" . "<img src=image_2.php?_nr=".$row['_nr']. " width=300 height=168/>" . "</td>  
    	</tr>
    
    </table>
    <table WIDTH=612px height=16 ></table>";   
    }
    Really hope you can help me understand.... I tried to search alot myself.

  2. #2
    Join Date
    Nov 2013
    Posts
    41
    You are not using CSS. You are using old ways of defining styles in the HTML tags. This is very old, deprecated, and doesn't give you much control. For a full introduction to CSS, take this very short, free online course: http://www.w3schools.com/css/. Also, Always use quotes with your HTML values.

    I probably have made an error in the PHP, so check your logs if it doesn't work. Tell me if you can't figure it out.
    Code:
    <style type="text/css">
    .bold {
      font-weight: bold;
    }
    table.table1 {
      background-color: #D8D8D8;
      border: 4px solid #A4A4A4;
      width: 515px;
    }
    table.table1 * {
      background-color: none;
      border: none;
    }
    td.table1_arrangement {
      border: none;
      background-color: #A4A4A4;
      width: 340px;
    }
    td.table1_beskrivelse {
      border: 0px solid #D8D8D8;
    }
    td.table1_title-Adresse {
      border: none;
      width: 70px;
      height: 15px;
    }
    td.table1_addresse {
      width: 10px;
    }
    td.table1_image2 {
      width: 20px;
    }
    table.table2 {
      width: 612px;
      height: 16px;
    }
    </style>
    <?php
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result)) {
    ?>
    <table class="table1">
      <tr>
        <td class="table1_arrangement" colspan="5">
         <span class="bold">&nbsp <?php echo $row['_arrangement'] ; ?> </span>
        </td>
      </tr>
      <tr>
        <td class="table1_beskrivelse" colspan="5">
          <?php echo $row['_beskrivelse']; ?>
        </td>
      </tr>
      <tr>
        <td class="table1_title-Adresse">
          <span class="bold">Adresse:</span>
        </td>
        <td colspan="2">
          <?php echo  $row['_adresse']; ?>
        </td>
        <td class="table1_addresse" rowspan="2">
          <a href="http://<?php echo $row['_link']; ?>" target="_blank"><img src="images/asd.png" style="border: none; width: 41px; height: 41px;" /></a>
        </td>
        <td></td>
      </tr>
      <tr>
        <td>
          <span class="bold">Link:</span>
        </td>
        <td colspan="2">
          <a href="http://<?php echo $row['_link']; ?>" target="_blank">
            <?php echo $row['_link']; ?>
          </a>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <img src="image.php?_nr=<?php echo $row['_nr']; ?>" style="width: 300px; height: 168px;" />
        </td>
        <td class="table1_image2" colspan="3">
          <img src="image_2.php?_nr=<?php echo $row['_nr']; ?>" style="width: 300px; height: 168px;" />
        </td>
      </tr>
    </table>
    <table class="table2"></table>
    <?php } ?>
    Happy to help. Also, in your PHP, it makes thing easier if you just add the echo where you need it, and not make the whole thing one. Look at how I did it.

  3. #3
    Join Date
    Nov 2013
    Posts
    3
    Thx alot. I will look into it all and return....... Hopefully 10% smarter, which wouldn't be much.

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,366
    <table bgcolor=D8D8D8 border=4 bordercolor=A4A4A4 WIDTH=515px>

    should be <table style="bgcolor=D8D8D8; border=4; bordercolor=A4A4A4; WIDTH=515px;">

    which is in-line CSS styling and it is not "OLD", it is a different way of applying specific CSS styling to an object.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  5. #5
    Join Date
    Nov 2013
    Posts
    3
    Guys you are amazing both of you...... The example's you used effort doing worked perfectly and made me understand what i did wrong..... I was so confused before, this is way more nice structured with the echo in the right places etc. etc.

    I appreciate the help more than you know, and i will learn from them very much and alot.

    Thx. a whole lot.

  6. #6
    Join Date
    Nov 2013
    Posts
    41
    @\\.\, It is old.
    The <body> bgcolor attribute is not supported in HTML5. Use CSS instead.
    The bgcolor attribute of <body> is deprecated in HTML 4.01.

    - http://www.w3schools.com/tags/att_body_bgcolor.asp. There is your proof.

    You may be familiar with the old HTML bgcolor attribute. This attribute (which was deprecated in HTML 4 and has been discontinued as of HTML 5) allowed you to set the background color of HTML elements. For example, using that attribute, you could set the background color of elements such as the <table> element or the <body> element.
    Although there is no CSS bgcolor property or attribute, there is the CSS background-color property. The background-color property is the CSS equivalent to the old HTML bgcolor attribute. Actually, the CSS background-color property is more powerful than the HTML bgcolor attribute. One major advantage of the background-color property is that it can be applied to any element.
    - http://www.quackit.com/css/css_bgcolor.cfm

    Also, test your new line of code. "style" refers to regular CSS. "bgcolor" does not exist in CSS, neither does "bordercolor" or an equals sign. It would be:
    HTML Code:
    <table style="background-color: 8D8D8; border: 4px solid A4A4A4; width: 515px;">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles