-1
すべての$ searchkey結果を強調表示したいと思います。 他のソリューションを試しましたが、検索エンジンでは機能しません。 結果が表に表示されます。 キーワードの外観をすべて強調表示したい。PHPハイライト入力検索キーワード
ありがとうございました!
<?php
$dbhost = 'xxx';
$username = 'xxx';
$password = 'xxx';
mysql_connect("$dbhost" , "$username", "$password");
mysql_select_db("xxx") or die("could not find the database!");
$output = '';
if(isset($_GET['search']))
{
$searchkey = $_GET['search'];
$query = mysql_query("SELECT * FROM xxx WHERE email LIKE '%$searchkey%' ") or die("Could not search");
$count = mysql_num_rows($query);
if ($count == 0)
{
$output = 'There was no search results !' ;
}
else
{
echo '<table class="table table-striped table-bordered table-hover">';
echo "<tr><th>email</th><th>hashkey</th></tr>";
while ($row = mysql_fetch_array($query))
{
$email = $row['email'];
$hashkey = $row['hashkey'];
echo "<tr><td>";
echo $email;
echo "</td><td>";
echo $hashkey;
echo "</td></tr>";
}
echo '<div>'."$count results were found for '$searchkey'.".'</div>'.'</br>';
}
echo "</table>";
$searchkey= $words;
}
?>
ありがとうございます! "i"は大文字と小文字を区別したくないので、どこに追加しますか? – alb
'i'を使用するとパターンの大文字小文字が区別されます。 'preg_replace( '/ $ searchkey。')/ is '、' \ 1 '、$ row [" email "]);' –