This is the result i get:
SELECT * FROM bible WHERE (book = '11' AND chapter= '8') AND (text_data LIKE '%return%' OR text_data LIKE '%turn%') ORDER BY id ASC<br>
SELECT * FROM bible WHERE (book = '30' AND chapter= '7') AND (text_data LIKE '%return%' OR text_data LIKE '%turn%') ORDER BY id ASC<br>
<h4>3) Return and Turn</h4><p></p><p class="BVerse"><span class="snavlink"><a href="http://www.blueletterbible.org/Bible.cfm?b=1ki&c=8&t=KJV" target="_blank">1Kings 8</a></span> - <span class="snavlink" style="font-size: 14px; font-weight: bold;"><a href="http://www.blueletterbible.org/assets/flash/mp3bibleplayer.cfm?b=11&c=8&t=KJV" target="_blank">Listen</a></span><br>
<span style="font-size: smaller; font-weight: bold; vertical-align: text-top;">14</span> And the king <span class="kw" id="" style="color: RGBA(20, 0, 0, 0.4); ">turn</span>ed his face about, and blessed all the congregation of Israel: (and all the congregation of Israel stood;)<br>
<span style="font-size: smaller; font-weight: bold; vertical-align: text-top;">33</span> When thy people Israel be smitten down before the enemy, because they have sinned against thee, and shall <span class="kw" id="" style="color: RGBA(20, 0, 0, 0.4); ">turn</span> again to thee, and confess thy name, and pray, and make supplication unto thee in this house:<br>
<span style="font-size: smaller; font-weight: bold; vertical-align: text-top;">35</span> When heaven is shut up, and there is no rain, because they have sinned against thee; if they pray toward this place, and confess thy name, and <span class="kw" id="" style="color: RGBA(20, 0, 0, 0.4); ">turn</span> from their sin, when thou afflictest them:<br>
<span style="font-size: smaller; font-weight: bold; vertical-align: text-top;">48</span> And so <span class="kw" id="" style="color: RGBA(20, 0, 0, 0.4); ">re<span class="kw" id="" style="color: RGBA(20, 0, 0, 0.4); ">turn</span></span> unto thee with all their heart, and with all their soul, in the land of their enemies, which led them away captive, and pray unto thee toward their land, which thou gavest unto their fathers, the city which thou hast chosen, and the house which I have built for thy name:<br>
<br><br><br><span style="font-size: 14px; font-weight: bold;"><a href="http://www.blueletterbible.org/Bible.cfm?b=amo&c=7&t=KJV" target="_blank">Amos 7</a></span> - <span style="font-size: 14px; font-weight: bold;"><a href="http://www.blueletterbible.org/assets/flash/mp3bibleplayer.cfm?b=30&c=7&t=KJV" target="_blank">Listen</a></span><br>
</p>
As you see the first query shows a result of words which are highlighted. But the 2nd query has no results. But in this case I would rather see nothing. I would rather see both queries filtered out. I want the results posted ONLY if both queries show results.
I have the attachment of this section of the code:
<?php
function give(){
global $db, $dbTable3, $spoke, $b1, $c1, $bk2, $ch2, $keyword_color1, $keyword_colorArr, $highlight, $h3, $comments, $commentsarray, $blblinks1, $blblinks2, $result;
echo $h3;
//echo $comments;
for($a=0; $a<count($keyword_colorArr);$a++){
$sql9Part = "SELECT * FROM ".$dbTable3." WHERE ";
//$sql9a .= $sql9Part."(";
$sql9a = $sql9Part."(book = '" .$b1. "' AND chapter= '" .$c1. "') ";
$sql9b = $sql9Part."(book = '" .$bk2. "' AND chapter= '" .$ch2. "') ";
//$sql9 .= ") ";
if(count($keyword_colorArr[$a]) != 0 ){
$sql9 = "AND (";
$sql9a .= $sql9;
$sql9b .= $sql9;
for($j=0; $j < count($keyword_colorArr[$a]);$j++){
if($j>0 && $j > count($keyword_colorArr[$a])-2){
$sql9a .= " OR ";
$sql9b .= " OR ";
}
$sql9a .= "text_data LIKE '%".$keyword_colorArr[$a][$j][0]."%'";
$sql9b .= "text_data LIKE '%".$keyword_colorArr[$a][$j][0]."%'";
if($j < count($keyword_colorArr[$a])-2){
$sql9a .= " OR ";
$sql9b .= " OR ";
}
}
$sql9a .= ")";
$sql9b .= ")";
}
$sql9a .= " ORDER BY id ASC";
$sql9b .= " ORDER BY id ASC";
/*echo $sql9a."<br />\n";
echo $sql9b."<br />\n";*/
// Step 3: Send the query
$result9a = $db->query($sql9a);
$result9b = $db->query($sql9b);
// Step 4: Iterate over the results
while($row9a = $result9a->fetch(PDO::FETCH_ASSOC)) {
$id9a[] = $row9a['ID'];
$bookSpoke9a[] = $row9a['book_spoke'];
$chapterSpoke9a[] = $row9a['chapter_spoke'];
$verseSpoke9a[] = $row9a['verse_spoke'];
$bookTitle9a[] = $row9a['book_title'];
$book9a[] = $row9a['book'];
$chapter9a[] = $row9a['chapter'];
$verse9a[] = $row9a['verse'];
$recordType9a[] = $row9a['recordType'];
$textData9a[] = $row9a['text_data'];
$bSpokeCycle9a[] = $row9a['b_spoke_cycle'];
$cSpokeCycle9a[] = $row9a['c_spoke_cycle'];
$vSpokeCycle9a[] = $row9a['v_spoke_cycle'];
}
while($row9b = $result9b->fetch(PDO::FETCH_ASSOC)) {
$id9b[] = $row9b['ID'];
$bookSpoke9b[] = $row9b['book_spoke'];
$chapterSpoke9b[] = $row9b['chapter_spoke'];
$verseSpoke9b[] = $row9b['verse_spoke'];
$bookTitle9b[] = $row9b['book_title'];
$book9b[] = $row9b['book'];
$chapter9b[] = $row9b['chapter'];
$verse9b[] = $row9b['verse'];
$recordType9b[] = $row9b['recordType'];
$textData9b[] = $row9b['text_data'];
$bSpokeCycle9b[] = $row9b['b_spoke_cycle'];
$cSpokeCycle9b[] = $row9b['c_spoke_cycle'];
$vSpokeCycle9b[] = $row9b['v_spoke_cycle'];
}
//var_dump($recordType9a);
//var_dump($recordType9b);
// for the first text
$resultFounda = "";
for($i=0; $i < count($recordType9a); $i++){
if(preg_match($keyword_colorArr[$a][$j][0], $subject, $matches)){
$resultFounda .= "<span style=\"font-size: smaller; font-weight: bold; vertical-align: text-top;\">".$verse9a[$i]."</span> ";
$strTexta = stripslashes($textData9a[$i]);
for($j=0; $j<count($keyword_colorArr[$a]);$j++){
$strTexta = preg_replace("/(".$keyword_colorArr[$a][$j][0].")/i", "<span class=\"kw\" id=\"\" style=\"color: ".$keyword_colorArr[$a][$j][1]."; \">$1</span>", $strTexta);
}
for($b=0; $b<count($highlight);$b++){
for($k=0; $k<count($highlight[$b]);$k++){
$strTexta = preg_replace("/(".$highlight[$b][$k][0].")/i", "<span class=\"kw\" id=\"\" style=\"color: ".$highlight[$b][$k][1]."; \">$1</span>", $strTexta);
}
}
$resultFounda .= $strTexta."<br />\n";
}
}
/******************************************************************************************************************/
// for the second text
$resultFoundb = "";
for($i=0; $i < count($recordType9b); $i++){
if(preg_match($keyword_colorArr[$a][$j][0], $subject, $matches)){
$resultFoundb .= "<span style=\"font-size: smaller; font-weight: bold; vertical-align: text-top;\">".$verse9b[$i]."</span> ";
$strTextb = stripslashes($textData9b[$i]);
for($j=0; $j<count($keyword_colorArr[$a]);$j++){
$strTextb = preg_replace("/(".$keyword_colorArr[$a][$j][0].")/i", "<span class=\"kw\" id=\"\" style=\"color: ".$keyword_colorArr[$a][$j][1]."; \">$1</span>", $strTextb);
}
for($b=0; $b<count($highlight);$b++){
for($k=0; $k<count($highlight[$b]);$k++){
$strTextb = preg_replace("/(".$highlight[$b][$k][0].")/i", "<span class=\"kw\" id=\"\" style=\"color: ".$highlight[$b][$k][1]."; \">$1</span>", $strTextb);
}
}
$resultFoundb .= $strTextb."<br />\n";
}
}
$h4 = "";
$h4 .= ($a+1).") ";
for($i=0; $i < count($keyword_colorArr[$a]); $i++){
if($i>0 && $i>(count($keyword_colorArr[$a])-2)){
$h4 .= " and ";
}else{
if($i>0){
$h4 .= ", ";
}
}
$h4 .= ucfirst($keyword_colorArr[$a][$i][0]);
}
/*
if(isset($bookTitle9a[0]) || isset($bookTitle9b[0])){
$table11 = strtolower($bookTitle9a[0]).$chapter9a[0]."_and_".strtolower($bookTitle9b[0]).$chapter9b[0];
$table11id = $recordType9a[0].$chapter9a[0]."_and_".$recordType9b[0].$chapter9b[0]."_ID";
$create6 = "CREATE TABLE IF NOT EXISTS ".$table11."
(".$table11id." int(5) NOT NULL AUTO_INCREMENT PRIMARY KEY,
date_time DATETIME,
spoke INT(3),
title varchar(120),
summary1 varchar(1000),
summary2 varchar(1000),
comments varchar(1000)
)";
$db->exec($create6);
//for($f=0; $f<count($bookSpoke4); $f++){
$insert11 = "INSERT INTO ".$table11." (
date_time,
spoke,
title,
summary1,
summary2,
comments
) VALUES (
'".date("Y-m-d H:i:s")."',
".$spoke.",
'".$h4."',
'".addslashes($resultFounda)."',
'".addslashes($resultFoundb)."',
'".$commentsarray[$a]."'
)";
echo $insert11."<br /><br /><br />";
//$affected_rows = $db->exec($insert);
$db->exec($insert11);
}
*/
echo "<h4>".$h4."</h4>";
//echo $comments;
echo "<p>".$commentsarray[$a]."</p>"; //starting from notes-isaiah17-isaiah61.php date 2016-04-09
echo "<p class=\"BVerse\">".$blblinks1;
echo $resultFounda;
echo "<br /><br /><br />";
echo $blblinks2;
echo $resultFoundb."</p>";
echo "<br /><br /><br />";
// empty the comments
$comments = "";
// empty the arrays
$id9a = Array();
$bookSpoke9a = Array();
$chapterSpoke9a = Array();
$verseSpoke9a = Array();
$bookTitle9a = Array();
$book9a = Array();
$chapter9a = Array();
$verse9a = Array();
$recordType9a = Array();
$textData9a = Array();
$bSpokeCycle9a = Array();
$cSpokeCycle9a = Array();
$vSpokeCycle9a = Array();
$id9b = Array();
$bookSpoke9b = Array();
$chapterSpoke9b = Array();
$verseSpoke9b = Array();
$bookTitle9b = Array();
$book9b = Array();
$chapter9b = Array();
$verse9b = Array();
$recordType9b = Array();
$textData9b = Array();
$bSpokeCycle9b = Array();
$cSpokeCycle9b = Array();
$vSpokeCycle9b = Array();
}
unset($keyword_colorArr);
return $result;
// }
}
?>