0

Below is my code which calls for a table to be created using php, it has very basic styling on it.

<?php
    $result = mysql_query("SELECT * FROM League ORDER BY Points DESC, Difference DESC, TeamName DESC");
    echo "<style>#size{height:100px;width:340px;overflow-y:scroll;}</style>";
    echo "<table id='size' border='1'>;
            <tr>
            <th>Team</th>
            <th>Played</th>
            <th>Won</th>
            <th>Drawn</th>
            <th>Lost</th>
            <th>For</th>
            <th>Against</th>
            <th>Difference</th>
            <th>Bonus Pts</th>
            <th>Points</th>
            </tr>";

    while($row = mysql_fetch_array($result))
    {
        echo "<tr>";
        echo "<td>" . $row['TeamName'] . "</td>";
        echo "<td>" . $row['Played'] . "</td>";
        echo "<td>" . $row['W'] . "</td>";
        echo "<td>" . $row['L'] . "</td>";
        echo "<td>" . $row['D'] . "</td>";
        echo "<td>" . $row['PF'] . "</td>";
        echo "<td>" . $row['PA'] . "</td>";
        echo "<td>" . $row['Difference'] . "</td>";
        echo "<td>" . $row['BonusPoints'] . "</td>";
        echo "<td>" . $row['Points'] . "</td>";
        echo "</tr>";  
    }
    echo "</table>";
?>

I have also created a way to style it in my CSS file below is the code

#customers
{
    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
    width:100%;
    border-collapse:collapse;
}
#customers td, #customers th 
{
    font-size:1em;
    border:1px solid #98bf21;
    padding:3px 7px 2px 7px;
}
#customers th 
{
    font-size:1.1em;
    text-align:left;
    padding-top:5px;
    padding-bottom:4px;
    background-color:#A7C942;
    color:#ffffff;
}

I'm aware that my table is not using the customer id for the table, but when I did it wouldn't work. So I added the simple styling at the top to see if it works and it did. Any suggestions how i can get it to use the customers styling? thanks

7
  • 1
    Did you include css file to you html? If so, there is no reason that #customers as table id should not work (try ctrl+f5 to refresh browser cache) Commented Apr 15, 2014 at 10:04
  • your css defines styles for the css id customers and your table has id size so obviously that won't work right? Commented Apr 15, 2014 at 10:07
  • i used to style to make a simple styling to see if it works it did. When i put customers in it didnt Commented Apr 15, 2014 at 10:08
  • change echo "<table id='size' border='1'>; to echo "<table id='customers' border='1'>; Commented Apr 15, 2014 at 10:09
  • @mark i have this in my header file <html> <head> <link rel="stylesheet" type"text/css" href="./css/websitestyle.css" /> </head> Commented Apr 15, 2014 at 10:09

1 Answer 1

1

As you are declaring your style can only be declared in head section of page..

Use style in this manner when u are declaring inside the code..

<?php

echo "<table id='size' style='height:100px;width:340px;overflow-y:scroll;' border='1'>";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.