-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 に答える