2013-10-12 154 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注入的侵害,这些注入可以用来窃取用户的身份。