2012-11-14 9 views
-3

글꼴 크기를 늘리고 첫 번째 셀에 파란색 배경을 추가하려고합니다. 그러나 나는 그것을 관리 할 수 ​​없었다.테이블 글꼴 크기 및 색상, PHP, HTML 변경 방법

// 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); 

어떻게 글꼴 크기를 증가시키고 위의 표에서 첫 번째 셀에 파란색 backgorund에를 추가 할 수 있습니까?

미리 감사드립니다.

+0

스타일링 등 배경 색상은 CSS를 통해 수행해야합니다. 이전에 CSS에 대한 경험이 있습니까? – Jrod

+0

php는 아무 관계가 없습니다. CSS가 필요 하겠지만 그 중 아무 것도 볼 수 없습니다. 이 코드가 폰트 크기로 어떤 것을 할 것으로 기대하십니까? – GolezTrol

+0

CSS 학습을 시작하십시오. 하드 코딩 된 ' '과 스타일 속성은 지난 10 년간 나쁜 습관으로 입증되었습니다. – deceze

답변

1

호프 this Helps! 텍스트 여기

<?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>