我有这段代码
<?php echo "<td class='name'><a href='humlaInfrastructure.php?title=".$humlainfrastructure["sn"][$i]."'>".$humlainfrastructure["title"][$i]."</a></td>"; ?>
我需要在其中添加另一个条件:
<a class="button red right" href="#" onClick="window.open('modules/addInfrastructureTitle.php','_new','fullscreen=no,location=no,width=600,height=200')"><strong>+</strong> New</a>
所以最终的代码变成了
<?php echo "<td class='name'><a href='humlaInfrastructure.php?title=".$humlainfrastructure["sn"][$i]."'>".$humlainfrastructure["title"][$i]."</a><a class="button red right" href="#" onClick="window.open('modules/addInfrastructureTitle.php','_new','fullscreen=no,location=no,width=600,height=200')"><strong>+</strong> New</a></td>"; ?>
但它显示错误。我该如何解决?
答案 0 :(得分:1)
试试这个
<?php echo "<td class='name'><a href='humlaInfrastructure.php?title=".$humlainfrastructure["sn"][$i]."'>".$humlainfrastructure["title"][$i]."</a><a class='button red right' href='#' onClick=\"window.open('modules/addInfrastructureTitle.php','_new','fullscreen=no,location=no,width=600,height=200')\"><strong>+</strong> New</a></td>"; ?>
使用反斜杠\
来转义引号
答案 1 :(得分:0)
试试这个
<?php echo "<td class='name'><a href='humlaInfrastructure.php?title=".$humlainfrastructure["sn"][$i]."'>".$humlainfrastructure["title"][$i]."</a><a class='button red right' href='#' onClick='window.open('modules/addInfrastructureTitle.php','_new','fullscreen=no,location=no,width=600,height=200')'><strong>+</strong> New</a></td>"; ?>
添加管理员权限:
<?php $str = "<td class='name'><a href='humlaInfrastructure.php?title='sdffd'>xfgdfgdfg</a>";
if($level=='Admin') {
$str .= "<a class='button red right' href='#' onClick='window.open('modules/addInfrastructureTitle.php','_new','fullscreen=no,??location=no,width=600,height=200')'><strong>+</strong> New</a>";
}
$str .= "</td>";
echo $str;
?>
答案 2 :(得分:0)
你试试看......
<?php echo "<td class='name'><a href='humlaInfrastructure.php?title=".$humlainfrastructure["sn"][$i]."'>".$humlainfrastructure["title"][$i]."</a><a class='button red right' href='#' onClick='window.open("."'modules/addInfrastructureTitle.php','_new','fullscreen=no,location=no,width=600,height=200')"."><strong>+</strong> New</a></td>"; ?>
答案 3 :(得分:0)
你需要逃避双引号。你的PHP字符串在双引号内,所以在字符串中你需要用单引号替换双引号或者用\
作为前缀:
<?php echo "<td class='name'><a href='humlaInfrastructure.php?title=".$humlainfrastructure["sn"][$i]."'>".$humlainfrastructure["title"][$i]."</a><a class='button red right' href='#' onClick=\"window.open('modules/addInfrastructureTitle.php','_new','fullscreen=no,location=no,width=600,height=200')\"><strong>+</strong> New</a></td>"; ?>
答案 4 :(得分:0)
试试这个
<?php echo "<td class='name'><a href='humlaInfrastructure.php?title=".$humlainfrastructure["sn"][$i]."'>".$humlainfrastructure["title"][$i]."</a><a class=\"button red right\" href=\"#\" onClick=\"window.open('modules/addInfrastructureTitle.php','_new','fullscreen=no,location=no,width=600,height=200')\"><strong>+</strong> New</a></td>"; ?>