doupin5667 2014-04-15 09:57
浏览 20

在echo php表上使用css

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

  • 写回答

1条回答 默认 最新

  • dstbp22002 2014-04-15 10:11
    关注

    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'>";
    
    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了