Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML表中的PHP变量在Chrome、Firefox和Safari中显示良好,但在IE8中显示较差_Html_Css_Internet Explorer_Cross Browser - Fatal编程技术网

HTML表中的PHP变量在Chrome、Firefox和Safari中显示良好,但在IE8中显示较差

HTML表中的PHP变量在Chrome、Firefox和Safari中显示良好,但在IE8中显示较差,html,css,internet-explorer,cross-browser,Html,Css,Internet Explorer,Cross Browser,下表显示了Chrome、Firefox和Safari的出色表现。其左侧显示如下所示: 但是,在Internet Explorer 8中,左侧部分有时显示如下: 在IE8中,只有变量$row[“username”]的顶部显示简短注释,即屏幕截图中的“admin”。如何使IE8在这种情况下显示完整的$row[“username”] 提前感谢, 约翰 源代码: echo "<table class=\"commentecho\">"; $count = 1; while ($row =

下表显示了Chrome、Firefox和Safari的出色表现。其左侧显示如下所示:

但是,在Internet Explorer 8中,左侧部分有时显示如下:

在IE8中,只有变量
$row[“username”]
的顶部显示简短注释,即屏幕截图中的“admin”。如何使IE8在这种情况下显示完整的
$row[“username”]

提前感谢,

约翰

源代码:

echo "<table class=\"commentecho\">";
$count = 1;
while ($row = mysql_fetch_array($result)) { 
    $dt1 = new DateTime($row["datecommented"], $tzFrom1);  
    $dt1->setTimezone($tzTo1);
    echo '<tr>';
    echo '<td style="border-left:2px solid #004993; border-bottom:2px solid #004993; border-top:2px solid #004993;" rowspan="3" class="commentnamecount">'.$count++.'</td>';
    echo '<td style="background: #CAE1FF; border-top:2px solid #004993;" class="commentname2user"><a href="http://www...com/.../index.php?profile='.$row["username"].'">'.$row["username"].'</a></td>';
    echo '<td style="border-right:2px solid #004993; border-bottom:2px solid #004993; border-top:2px solid #004993;" rowspan="3" class="commentname1" id="comment-' . $row["commentid"] . '">'.stripslashes($row["comment"]).'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td style="background: #CAE1FF;" class="commentname2">'.$dt1->format('F j, Y').'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td style="background: #CAE1FF; border-bottom:2px solid #004993;" class="commentname2a">'.$dt1->format('g:i a').'</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="commentname2a"></td>';
    echo '</tr>';
    }
echo "</table>";

这看起来像是一个线条高度问题。尝试在.commentname2user和.commentname1的行高上放置一个实际像素/设置一个值。好吧,您确实要求链接只有这么高:

table.commentecho td a {
    height: 20px;
}
诀窍是,这不应该起作用,而且在大多数浏览器中也不起作用:根据CSS标准,
height
明确地不适用于内联元素,比如
,它无论如何都适用。因此:

  • 删除无效的
    高度:
    属性
  • 确保为页面提供标准模式DOCTYPE声明。你不会想要怪癖模式,它充满了像这样令人讨厌的遗留兼容性错误

另外,在将数据字符串模板化为HTML时,请记住使用
htmlspecialchars()
,否则会存在跨站点脚本漏洞
stripslashes()
不能完成这项工作,几乎可以肯定这是一个错误。

我对您的php代码和css做了一些安排,但这在两种浏览器中看起来几乎相同,希望这对您有所帮助

PHP代码:

echo '<table class="comments" cellspacing="0">';
$count = 1;
while ($row = mysql_fetch_array($result)) { 
    $dt1 = new DateTime($row["datecommented"], $tzFrom1);  
    $dt1->setTimezone($tzTo1);
    echo '<tr>';
    echo '<td class="comment-count">'.$count++.'</td>';
    echo '<td class="comment-user">';
    echo '<a href="http://www...com/.../index.php?profile='.$row["username"].'">'.$row["username"].'</a>'
    echo '<br/><span class="comment-date">'.$dt1->format('F j, Y').'</span><br/>';
    echo '<span class="comment-hour">'.$dt1->format('F j, Y').'</span>';
    echo '</td>';
    echo '<td class="comment-text" id="comment-' . $row["commentid"] . '">'.stripslashes($row["comment"]).'</td>';
    echo '</tr>';
    }
echo "</table>";

啊,好的。我试试看。就htmlspecialchars()而言,您是否在保存作为安全预防措施?我应该将其放在所有PHP变量上?是的。无论您在何处获取一个纯文本字符串并将其放入HTML,都需要对其进行编码以适应该上下文。这不仅仅是安全问题;安全性是正确性的一种特殊情况。输入<代码>
echo '<table class="comments" cellspacing="0">';
$count = 1;
while ($row = mysql_fetch_array($result)) { 
    $dt1 = new DateTime($row["datecommented"], $tzFrom1);  
    $dt1->setTimezone($tzTo1);
    echo '<tr>';
    echo '<td class="comment-count">'.$count++.'</td>';
    echo '<td class="comment-user">';
    echo '<a href="http://www...com/.../index.php?profile='.$row["username"].'">'.$row["username"].'</a>'
    echo '<br/><span class="comment-date">'.$dt1->format('F j, Y').'</span><br/>';
    echo '<span class="comment-hour">'.$dt1->format('F j, Y').'</span>';
    echo '</td>';
    echo '<td class="comment-text" id="comment-' . $row["commentid"] . '">'.stripslashes($row["comment"]).'</td>';
    echo '</tr>';
    }
echo "</table>";
table.comments{
    margin: 20px 0 30px;
    width: 450px;
}
table.comments td{
    vertical-align:top;
    border: solid #004993;
    border-width:2px 0 2px 0;
}
table.comments td.comment-count{
    border-left: 2px solid #004993;
    width: 50px;
    font:bold 25px Arial, Helvetica, sans-serif;
    color: #004993;
    vertical-align: top;
    padding:2px 0 0 5px;
}
table.comments td.comment-user{width:120px;background-color:#CAE1FF;padding: 5px;}
table.comments td.comment-user a{
    font:bold 14px/20px Arial, Helvetica, sans-serif; 
    text-decoration:none;
    color: #004284;
    padding:2px;
}
table.comments td.comment-user a:hover{background-color: #004284; color:#CAE1FF;}
table.comments td.comment-user span.comment-date, span.comment-hour{
    font:11px Arial, Helvetica, sans-serif;
}
table.comments td.comment-text{
    border-right: 2px solid #004993;
    width: 410px;
    font: normal 14px/20px Georgia, "Times New Roman", Times, serif;
    padding-left: 10px;
}