-3

我正在尝试增加字体大小并为第一个单元格添加蓝色背景,但我无法管理它。

// sending query
$result = mysql_query("SELECT `UserName`,`UserScore` FROM {$table} ORDER BY `UserScore` DESC");
if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);


echo "<table border='1' align='center'><tr>";
// printing table headers
//for($i=0; $i<$fields_num; $i++)
//{
  //  $field = mysql_fetch_field($result);
    echo "<td>Name &nbsp;&nbsp;&nbsp;&nbsp;</td>";
    echo "<td>Score &nbsp;&nbsp;&nbsp;&nbsp;</td>";
//}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
    echo "<tr>";

    // $row is array... foreach( .. ) puts every element
    // of $row to $cell variable
    foreach($row as $cell)

        echo "<td>$cell</td>";


    echo "</tr>\n";
}
mysql_free_result($result);

如何增加字体大小并为上表中的第一个单元格添加蓝色背景?

4

1 回答 1

1

希望这可以帮助!

<?php
$result = mysql_query("SELECT `UserName`,`UserScore` FROM {$table} ORDER BY `UserScore` DESC");
if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);


echo "<table border='1' align='center'><tr>";
// printing table headers
//for($i=0; $i<$fields_num; $i++)
//{
  //  $field = mysql_fetch_field($result);
    echo "<td>Name &nbsp;&nbsp;&nbsp;&nbsp;</td>";
    echo "<td>Score &nbsp;&nbsp;&nbsp;&nbsp;</td>";
//}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
    echo "<tr>";

    // $row is array... foreach( .. ) puts every element
    // of $row to $cell variable
    $i = 0;
    foreach($row as $cell)
    {
       if($i == 0)
           $class = "class = 'backg'";
       else
           $class = "class = ''";
        echo "<td ".$class.">$cell</td>";

     $i++;
    }
    echo "</tr>\n";
}
mysql_free_result($result);
?>

这里的风格

<style>
.backg{background:blue;font-size:18px;}
</style>
于 2012-11-14T15:51:32.013 回答