...

View Full Version : Boolean search select statements



egnjohn
01-11-2012, 04:55 PM
I do not know what I have done wrong with my coding, the search for all keywords doesnt work. I get the same results as the any keyword search. I am fairly new to coding, so it is probably a very simple fix. Please let me know what I did wrong. Below is the form and the table query coding.


echo "<form id=\"form4\" name=\"form4\" method=\"get\" action=\"modules.php?\">";
echo "<input value=\"Bible\" name=\"name\" type=\"hidden\" />";
echo "<input value=\"search_results\" name=\"call\" type=\"hidden\" />";
echo "<input size=\"50\" name=\"query\" title=\"Search Keywords\"/>";
echo "<input value=\"$version\" type=\"hidden\" name=\"version\" />";
echo "<br />";
echo "<input value=\"entire_bible\" checked=\"checked\" type=\"radio\" name=\"criteria\" title=\"Search Entire Bible\"/>";
echo "&nbsp;Entire Bible";
echo "&nbsp;&nbsp;<input value=\"old_testament\" type=\"radio\" name=\"criteria\" title=\"Search Old Testament\"/>";
echo "&nbsp;Old Testament";
echo "&nbsp;&nbsp;<input value=\"new_testament\" type=\"radio\" name=\"criteria\" title=\"Search New Testament\"/>";
echo "&nbsp;New Testament";
echo "<br /><br />";
echo "<input value=\"any\" checked=\"checked\" type=\"radio\" name=\"search_type\" title=\"Match Any Word\"/>";
echo "&nbsp;Match Any Word";
echo "&nbsp;&nbsp;<input value=\"all\" type=\"radio\" name=\"search_type\" title=\"Match All Words\"/>";
echo "&nbsp;Match All Words";
echo "<br />";
echo "<input value=\"exact\" type=\"radio\" name=\"search_type\" title=\"Match Exact Phrase\"/>";
echo "&nbsp;Match Exact Phrase";
echo "&nbsp;&nbsp;<input value=\"verse\" type=\"radio\" name=\"search_type\" title=\"Match Book Chapter:Verse\"/>";
echo "&nbsp;Match Book Chapter:Verse";
echo "<br><br>";
echo "<input value=\"Submit\" type=\"submit\" />";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<input value=\"Reset\" type=\"reset\" />";
echo "</form>";



if($search_type=='any'){
if($criteria=='entire_bible'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('*$query*' IN BOOLEAN MODE)");
}
if($criteria=='old_testament'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('*$query*' IN BOOLEAN MODE) && testament='old'");
}
if($criteria=='new_testament'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('*$query*' IN BOOLEAN MODE) && testament='new'");
}
}//if any

if($search_type=='all'){
$query = ereg_replace(" ", " +", "$query");
if($criteria=='entire_bible'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('{$query}' IN BOOLEAN MODE)");
}
if($criteria=='old_testament'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('{$query}' IN BOOLEAN MODE) && testament='old'");
}
if($criteria=='new_testament'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('{$query}' IN BOOLEAN MODE) && testament='new'");
}
}//if all

if($search_type=='exact'){
if($criteria=='entire_bible'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('\"{$query}\"' IN BOOLEAN MODE)");
}
if($criteria=='old_testament'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('\"{$query}\"' IN BOOLEAN MODE) && testament='old'");
}
if($criteria=='new_testament'){
$result4 = $db->sql_query("select * FROM Bible$version WHERE MATCH (scripture) AGAINST ('\"{$query}\"' IN BOOLEAN MODE) && testament='new'");
}
}//if exact

if($search_type=='verse'){
$i = strrpos($query, " ");
$query=substr_replace($query, ":", $i, 1);
$query2 = explode(":", $query);
$bookquery = $query2[0];
$chapterquery = $query2[1];
$versequery = $query2[2];
$result4 = $db->sql_query("select * FROM Bible$version WHERE book = '$bookquery' AND chapter= '$chapterquery' AND verse ='$versequery'");
}//if verse

global $db;
while ($row = $db->sql_fetchrow($result4)) {
$testament = $row['testament'];
$book = $row['book'];
$chapter = $row['chapter'];
$verse = $row['verse'];
$scripture = $row['scripture'];

echo "<b><a href=\"modules.php?name=Bible&call=chapter&viewbook=$book&viewchapter=$chapter&version=$version\">$book</a>&nbsp;$chapter:$verse</b>";
echo "<br>";
echo "$scripture";
echo "<hr>";
}//result 4

if(!$query){
echo "<b>You did NOT enter any keywords.</b><br>";
}
if(!$scripture){
echo "<b>No results found.</b>";
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum