2014-12-26 2 views
1

PHP/MySQL의 찾기 및 바꾸기 기능을 시도하고 있으며 내가하는 일은 페이지의 데이터베이스에서 모든 데이터를 표시 한 다음 같은. 내가이 모든 필드를 표시합니다 '주권'과 같은 문자열을 발견하면 지금PHP에서 MySQL 데이터베이스에서 가져온 데이터에 스타일을 적용하는 방법

'SELECT "office_phone" as col_name, id, office_phone as search_string, trim(replace(concat(" ",LOWER(office_phone)," ")," '.$find.' "," '.$replace.' ")) as replace_string FROM `employees` WHERE (office_phone like "'.$find.' %" OR office_phone like "% '.$find.' %" OR office_phone like "% '.$find.'" OR office_phone LIKE "'.$find.'")'; 

지금 내가 만들고 싶어 ... 열 "office_phone"에서 문자열 주권을했다 : 아래 내가 동일한 작업을 수행하기 위해 사용하고있는 쿼리입니다 Raj 사무실 번호와 같은 굵은 글씨 만 (발견 된 문자열)은 123456789입니다.이 'Raj'는 대담 해져야합니다. 누구든지 신속하게 도와주세요.

+1

이것은 단지 + "검색 문자열을 선택" "방출 임의의 HTML 덩어리에 스타일을 적용"기본적으로. 적절하게 해결하십시오. 이 질문은 이상하게 구체적입니다. –

+0

실제로 당신은 당신이 얻고있는 특정한 내용에 스타일 태그를 만들 수 있습니다. 예를 들어, ..... 이것은 귀하의 문제 –

+0

이 내가 이미이 전체 문장을 만들려고/굵은 글씨로 내용을 굵게하지만 난 단지 특정 문자열을 원한다 –

답변

0

너의 일을해라. 당신이 다음 대소 문자를 확인하려면 사용 :

str_replace 

str_ireplace 

의 insted.

<!DOCTYPE html> 
<html> 
<body> 

<?php 
$str="hello this is a good book. Hello, did you like the book. helloare you there?"; 
$strrep="hello"; 
$str = str_ireplace($strrep,'<b>'. $strrep.'</b>',$str); 
echo "$str"; 
?> 

</body> 
</html> 
0
$string = "I am trying a find and replace functionality for PHP/MySQL, and the first thing what i am doing is displaying all the data from database on a page and then display the same. below is the query i am using to do the same"; 
$searchingFor = "/" . $searchQuery . "/i"; 
$replacePattern = "<b>$0<\/b>"; 
preg_replace($searchingFor, $replacePattern, $string); 
관련 문제