1

我目前正在开发一个项目,该项目从 mySQL 中提取表,这些表显示在 html 表中。下面你可以看到代码。

if (mysql_num_rows($result) > 0) { 
    // yes 
    // print them one after another 
    echo "<table cellpadding=1 border=1 width=100%>"; 
    while($row = mysql_fetch_row($result)) { 
        echo "<tr>";  
                echo "<td>"."<center>".$row[0]."</center>"."</td>"; 

        echo "<td>" .$row[2]."</td>"; 
        echo "<td>" .$row[1]."</td>"; 
        echo "<td>" .$row[3]."</td>";  
        echo "</tr>"; 
    } 
    echo "</table>"; 
} 

我需要将其更改为

if (mysql_num_rows($result) > 0) { 
    // yes 
    // print them one after another 
    echo "<table cellpadding=1 border=1 width=100%>"; 
    while($row = mysql_fetch_row($result)) { 
        echo "<tr>";  
                echo "<td>"."<center>".$row[0]."</center>"."</td>"; 

        echo "<td>" .$row[2]."</td>"; 
        echo "<td>" .$row[1]."</td>"; 
        echo "<td><font face="Georgia, Times New Roman, Times, serif">" .$row[3]."</font></td>";    
        echo "</tr>"; 
    } 
    echo "</table>"; 
} 

当我这样做时,会抛出错误。我这样做是为了让用户看到我有字体的条形码。

我做错了吗?还是有另一种更好的方法。

谢谢瑞恩

4

3 回答 3

1

将 " 更改为 ' 表示脸:

 echo "<td><font face='Georgia, Times New Roman, Times, serif'>" .$row[3]."</font></td>"; 

此外,您应该使用 css 类或 id 而不是内联字体。(检查这个例如css类应用css到一个php表

于 2013-07-12T11:11:56.057 回答
0

尝试

echo "<td><font face='Georgia, Times New Roman, Times, serif'>" .$row[3]."</font></td>";
于 2013-07-12T11:12:30.337 回答
0

OMG .. 不要使用font标签。自 HTML 4.01 起已弃用,在 HTML 5 中不可用。错误来自未正确转义。

echo "<td><font face=\"Georgia, 'Times New Roman', Times, serif\">" ...

但是请使用一个类并使用 CSS 进行样式设置。

echo "<td class=\"font-georgia\">...

在 CSS 中:

.font-georgia {
    font-family: Georgia, 'Times New Roman', Times, serif;
}

注意引号,'Times New Roman'因为它有空格。

center标签也一样。改用text-align:centerCSS。

于 2013-07-12T11:15:03.443 回答