到目前为止,这是我的代码
<form method="post" name="search">
<input type="search" name="k" placeholder="Enter Keywords">
<input type="submit" value="Search">
</form>
<?
$skw = $_POST['k'];
if(isset($_POST['k'])){
$connect = mysql_connect('*', '*', '*')or die('Could not execute command. Please contact a administrator.');
mysql_select_db('*')or die('No database');
$query = "SELECT * FROM *** WHERE items LIKE '%$skw%'";
$result = mysql_query($query)or die(mysql_error());
echo "<table align=\"left\" border=\"1\" cellpadding=\"5\" cellspacing=\"3\">";
echo "\"" . $skw . "\"";
if(empty($result)){echo " Not Found!";}else{
echo " Found In";
while($row = mysql_fetch_array($result)){
echo "<tr><td>";
echo "<font color=\"#CC0000\">" . $row['tub_id'] . "</font>";
echo "</td><td>";
echo $row['items'];
echo "</td></tr>";
}
echo "</table>";
}}?>
如何在结果中突出显示 $skw?我曾尝试使用 preg_replace,但我对 php 很陌生,无法让它工作。我知道我可以使用类来设置它的样式。感谢您的任何帮助。