View Single Post
  #2 (permalink)  
Old 08-06-2008, 03:55 PM
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 247
$bigWords is an array of words > 4 letters. The rest of the words have previously sorted out.
PHP Code:
function getQuery($bigWords){

        
$query="SELECT * FROM bible WHERE 1=1 AND";
    
        
//to sort out all words with length less than 4 like AND, OR, BUT...
        
for ($i=0$i count($bigWords); $i++){
            if(
$bigWords[$i]!=""){
                
$query.=" CASE WHEN text_data LIKE '%" .$bigWords[$i]. "%' THEN 1 ELSE 0 END\n";
                if(
$i!=count($bigWords)-1){
                    
$query.=" +";
                    }else{
                    
//removes the OR from the last line and replaces with the following
                    //for results of words > 3
                    
$query.= " > 3";
                    }
                }
            }
        
$query .= " ORDER BY id";
        
$theresult = array();
        
//$theresult[] = "";
        //$theresult[] = $query;
        
$result mysql_query($query);

    while(
$row mysql_fetch_assoc($result)){
        
$strText $row['text_data'];
        
$COLORS = array('red','Teal','blue','Magenta','green','PaleGreen','orange','purple','Pink','YellowGreen','Sienna','aqua','Gray','LightBlue','MediumTurquoise','DarkRed');
        for(
$m=0$m count($bigWords); $m++){
            
$strText preg_replace("/(".$bigWords[$m].")/i""<span class=\"\" id=\"\" style=\"color:".$COLORS[$m]."; font-weight:bold;\">$1</span>"$strText);
            }
        
$theresult[] = "<br />\n<span class=\"goToBookChapter\" style=\"font-weight: bold;\">".$row['book_title']." ".$row['chapter'].":".$row['verse']."</span><br />\n".$strText;
        }
        return 
$theresult;
        echo 
"<br /><br />".$query."<br />";

__________________
Gilgal's website:
Wheel Of God
Now easy to post scripture verses!
Portfolio
Reply With Quote