2013-10-12 127 views
1

如何使用此代碼更改字體顏色?我只是在尋找一個簡單的解決方案,但如果你還想建議如何將其重寫爲SQL注入證明,我也會很感激。請幫助,因爲我還在學習。使用數組更改字體顏色,字體大小

echo "<table>"; 
echo "<table border='0' width='800' align='center' >"; 
echo "<td width='40%' align='center'></td> 
<td width='20%' align='center'></td> 
<td width='40%' align='center'></td>"; 
echo "</tr>"; 

$row_number = 1; 
while ($row = mysql_fetch_array($result)) { 

    $id_actor = $row["id_actor"]; 
    $idfilm = $row["idfilm"]; 
    $filmTitle = $row["filmTitle"]; 
    $filmRole = $row["filmRole"]; 
    $filmDirector = $row["filmDirector"]; 

    for($i = 0; $i < 3; $i++) { 
     echo "<td> $row[$i]</td>"; 
    } 
    echo "</tr>"; 

    $row_number++; 
} 
echo "</table>"; 

回答

0

相反的echo"<td> $row[$i]</td>";,嘗試
echo"<td><font color=\"red\"> $row[$i]</font></td>";

+0

謝謝你的工作。 – user2714558

2

在你的代碼的開頭,插入CSS樣式如下:

echo " 
<style> 
tr:nth-child(2n+1) { 
    background-color: #ccc; 
} 
</style>" 
0

你可以把這個例子,您的問題:

<font color="red">This is some text!</font> 

解決字體顏色的問題。或者,你可以使用CSS樣式:

style="color: #CC0000;" 

由於有關建議,以保護自己免受SQL注入是很難做出的任何建議,您的示例代碼不包含您的查詢的SQL注入攻擊已經作出了當我們到達您的示例代碼時會造成破壞但對於一般提示,請閱讀thisthis。最後,不要忘記保護你的客戶端免受XSS注入的侵害,這些注入可以用來竊取用戶的身份。