在搜索功能中正确显示数据库值的双引号

时间:2013-05-07 04:09:01

标签: php html sql-server forms

我做了一个这样的搜索表单:

enter image description here

这是我的代码:

<?php
include "config/koneksi.php";
$qPart = $_POST['qPart'];
$result=mssql_query("SELECT DISTINCT ProductName as Nama from tblMstProductUHT1 where ProductName LIKE '$qPart%'");
function boldThat($partq, $realValue){
//$partq = Asep
//$realValue = Aseptic
$Length = strlen($partq);
$Length2 = strlen($realValue);
$mainLength = $Length - $Length2;
$notBolded = substr( $realValue, 0, $mainLength);
$Bolded = substr ($realValue,$mainLength);
return $notBolded . "<strong>" . $Bolded . "</strong>";
}
 while($row=mssql_fetch_array($result)){
 echo"<div id='link' onclick='addText.(\"".$row['Nama']."\";'>".boldThat($qPart,$row['Nama'])."</div>";
 }
?>

问题是当您单击其中一个文本时,它显示不正确,因为文本包含双引号。知道如何在搜索文本中正确显示双引号吗?

0 个答案:

没有答案