2013-12-23 30 views
0

我有這樣的代碼結合了超鏈接字符串的單一顯示內

<?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

你報價錯誤 –

+0

是什麼你得到的錯誤信息?發佈到SO時,包含您在屏幕上看到的錯誤總是有幫助的。 – Robbert

回答

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; 
?> 
+0

謝謝,它工作。 – Code4Code

+0

如果我必須添加管理員角色才能訪問此任務,將會如何。 <?php echo「".$humlainfrastructure["title"][$i]." if($ level =='Admin'){+ New}」;?> – Code4Code

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>"; ?> 
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>"; ?> 

使用反斜槓\來逃避報價

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>"; ?> 
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>"; ?>