I'm getting frustrated at this. This is not working: //paging $page = isset($_GET['page']) ? $_GET['page'] : 1; //or you can use the ternary operator //$resultspertpage = 10; $perpage = 10;// number of records per page $end = $page*$perpage; // present page $start=($page-1)*$perpage; /******************************************************************************/ //$sql="SELECT count(*)totalrows FROM bible WHERE 1=1 AND"; $sql="SELECT * FROM bible WHERE 1=1 AND"; $j=0; //to sort out all words with length less than 4 like AND, OR, BUT... for ($i=0; $i < count($searchTheseArr); $i++){ if(strlen($searchTheseArr[$i]) > 4){ $newSearchTheseArr[$j] = $searchTheseArr[$i]; //j renumbers the words of length 4 and up $j++; } } //sql searches only length 4 and up for ($j=0; $j < count($newSearchTheseArr); $j++){ $sql.=" CASE WHEN text_data LIKE '%" .$newSearchTheseArr[$j]. "%' THEN 1 ELSE 0 END"; //$sql.=" text_data LIKE '%" .$newSearchTheseArr[$j]. "%'"; if($j!=count($newSearchTheseArr)-1){ $sql.=" +"; //$sql.=" OR"; }else{ //removes the OR from the last line and replaces with the following $sql.= " > 3"; $sql.= " LIMIT " . $start . ", " . $perpage; } } PHP:
try and output the $sql variable after the line and see what happens if you query it in a MySQL admin tool
I get: But let me tell you. The option shows only page 1. Only 10 results. I even added an a tag going to the next page but it shows error: