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 6 of 6

Thread: table

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    table

    My code below displays data from the database in a table.
    Im finding it hard to change the font of the data in the table.
    Where can i do this? When i add a font tag just after the <table> tag and the closing tag before the </table> tag i get errors??

    thanks




    <?php echo "<table border='1'>
    <tr>
    <th>Product Code</th>
    <th>Name</th>
    <th>Product Type</th>
    <th>Picture</th>
    <th>Description</th>
    <th>Stock</th>
    <th>Price</th>


    </tr>";

    while($row = @mysql_fetch_array($result))
    {

    if ($row['Department'] == $var)
    {
    echo "<tr>";
    //echo "<td>" . $row['Department'] . "</td>";
    echo "<td>" . $row['Prod_code'] . "</td>";
    echo "<td>" . $row['Name'] . "</td>";
    echo "<td>" . $row['Prod_Type'] . "</td>";
    echo "<td><img height = 50 width = 50 src = " . $row['Picture'] . "></td>";
    echo "<td>" . $row['Description'] . "</td>";
    echo "<td>" . $row['Stock'] . "</td>";
    echo "<td>" . $row['Price'] . "</td>";
    echo "</tr>";
    }
    }
    echo "</table>";mysql_close($con);
    ?>

  • #2
    Regular Coder
    Join Date
    Feb 2007
    Location
    near Washington, DC
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Stay far, far away from the <font> tag. Use CSS instead to style your <td>s and <th>s, something like this:
    Code:
    td {
        font-family:verdana,arial,sans-serif;
        font-size:12px;
        color:#330;
    }
    th {
        font-family:georgia,times,serif;
        font-size:12px;
        font-weight:bold;
        color:#000;
        background-color:#DEF;
    }
    The <font> tag is deprecated and it is evil.
    — Wilford Nusser
    Validate Your Code: (X)HTML CSS
    An HTML Email is NOT a Web Page: HTML Email Guide (1.2Mb pdf) Webmail CSS Support
    REGEX: Brought to you by Psychotic Crack-Smoking Monkeys

  • #3
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    problem is, this code is within a page and i dont want to change the font for the whole page.just for the table!

    thanks

  • #4
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ok blonde moment
    sorry!
    i got it
    thanks that's working great!

  • #5
    Regular Coder
    Join Date
    Feb 2007
    Location
    near Washington, DC
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bunny1 View Post
    problem is, this code is within a page and i dont want to change the font for the whole page.just for the table!
    The css I gave won't change it for the whole page, unless the whole page is formatted using <table>s. If that's the case, change this in the first line of your php:
    PHP Code:
    <?php echo "<table border=\"1\" class=\"mytable\">
    and change this in the css I've given:
    Code:
    .mytable td {
        font-family:verdana,arial,sans-serif;
        font-size:12px;
        color:#330;
    }
    .mytable th {
        font-family:georgia,times,serif;
        font-size:12px;
        font-weight:bold;
        color:#000;
        background-color:#DEF;
    }
    — Wilford Nusser
    Validate Your Code: (X)HTML CSS
    An HTML Email is NOT a Web Page: HTML Email Guide (1.2Mb pdf) Webmail CSS Support
    REGEX: Brought to you by Psychotic Crack-Smoking Monkeys

  • #6
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    pheonixshade is correct all styling of... well anything should be done with css
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

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