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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change html table font style in php

    I'm using the following code to display data from my database but how do i change the font size, type of the table cells?

    Code:
    //Retrive all the data from the table
    $result = mysql_query("SELECT * FROM stats2") or die(mysql_error());  
    
    echo "<table border='1' cellspacing='0' width='593'>";
    echo "<tr> <th bgcolor='#BFBFBF' align='center'>Name</th> <th bgcolor='#BFBFBF' align='center'>Apps(Sub)</th> <th bgcolor='#BFBFBF' align='center'>Goals/CS</th> <th bgcolor='#BFBFBF' align='center'>Yellows</th> <th bgcolor='#BFBFBF' align='center'>Reds</th> <th bgcolor='#BFBFBF' align='center'>MOTM</th> </tr>";
    
    
    // keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
    
    // Print out the contents of each row into a table
    echo "<tr><td align='center'>"; 
             echo $row['name'];
    echo "</td><td align='center'>"; 
    	echo $row['apps']; echo '('; echo $row['sub']; echo ')';
    echo "</td><td align='center'>"; 
    	echo $row['goals'];
    echo "</td><td align='center'>"; 
            echo $row['yellows']";
    echo "</td><td align='center'>"; 
             echo $row['reds'];
    echo "</td><td align='center'>"; 
    	echo $row['MOTM'];
    echo "</td></tr>"; 
    } 
    
    echo "</table>";

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    with css.....

    <style type="text/css">
    td { your styles here.. }
    tr { your styles here.. }
    </style>

    ??

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Adee View Post
    with css.....

    <style type="text/css">
    td { your styles here.. }
    tr { your styles here.. }
    </style>

    ??
    Where would I place this code?

    Tried a couple of times put doesn't seem to work

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Quote Originally Posted by daza93 View Post
    Where would I place this code?

    Tried a couple of times put doesn't seem to work
    PHP Code:
    echo <<<CSS
    <style type="text/css">
    td { font-family: courier; color: red; }
    </style>
    CSS; 

  • #5
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,498
    Thanks
    72
    Thanked 105 Times in 104 Posts
    Make a new file, put in the CSS coding such as Adee has shown below, and save with with a name like style.css

    Code:
    <style type="text/css">
    td { font-family: courier; color: red; }
    </style>
    Then in the file where you want to use it, in the header put this.

    Code:
    <link rel="stylesheet" type="text/css" href="mystyle.css" />
    change mystyle.css to the path and name of your file.
    Been a sign maker for 7 years. My business:
    American Made Signs


  •  

    Posting Permissions

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