Creating a search engine with pagination using mysqli database connection

Hello My name is Abraham and i trying to create a search engine with pagination ,i created one using database connection mysql instead of mysqli,
I then tried to create one using mysqli connection but the pagination is functioning properly


      

        
      
<?php
   
$button = $_GET ['submit'];
$search = $_GET ['search'];
 
if(strlen($search)<=1)
echo "Search term too short";
else{
echo "You searched for <b>$search</b> <hr size='1'></br>";
mysql_connect("localhost","root","");
mysql_select_db("register");
   
$search_exploded = explode (" ", $search);
 
$x = "";
$construct = "";  
   
foreach($search_exploded as $search_each)
{
$x++;
if($x==1)
 $construct .="keyword LIKE '%$search_each%' OR qualifications1 LIKE '%$search_each%' OR dept LIKE '%$search_each%' ";
                           else
                                  $construct .="AND keyword LIKE '%$search_each%' OR AND qualifications1 LIKE '%$search_each%' OR AND dept LIKE '%$search_each%' ";
   
}
 
$constructs ="SELECT * FROM users WHERE $construct";
$run = mysql_query($constructs);
   
$foundnum = mysql_num_rows($run);
   
if ($foundnum==0)
 echo "Sorry, there are no matching result for <b> $search </b>. </br> </br> 1. Try more keywords. for example: If you want to search 'For a person in the Banking Department' then use general keyword like 'Banking','Business','Finance' or if the person needed resides in the Information  technology Department, then use general keyword like 'I.T' ,'Information, technology','Informatics' etc. <br> </br> 2. Try different words with similar  meaning </br><br> 3. Please check your spelling";
else
{
 
echo "$foundnum results found !<p>";
 
$per_page = 1;
$start = isset($_GET['start']) ? $_GET['start']: '';
$max_pages = ceil($foundnum / $per_page);
if(!$start)
$start=0;
$getquery = mysql_query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");
 
while($runrows = mysql_fetch_assoc($getquery))
{
$id=$runrows['id'];
            $firstname = $runrows ['firstname'];
            $job_type = $runrows ['job_type'];
            $about = $runrows ['about'];
            $dept = $runrows ['dept'];
            $gender = $runrows ['gender'];
            $nationality = $runrows ['nationality'];
            $marital_status = $runrows ['marital_status'];
            $computer_literate = $runrows ['computer_literate'];
            $computer_literate2 = $runrows ['computer_literate2'];
            $computer_literate3 = $runrows ['computer_literate3'];
            $computer_literate4 = $runrows ['computer_literate4'];
            $computer_literate5 = $runrows ['computer_literate5'];
            $computer_literate6 = $runrows ['computer_literate6'];
            $computer_literate7 = $runrows ['computer_literate7'];
            $computer_literate8 = $runrows ['computer_literate8'];
            $computer_literate9 = $runrows ['computer_literate9'];
            $lang_spoken = $runrows ['lang_spoken'];
            $lang_spoken2 = $runrows ['lang_spoken2'];
            $lang_spoken3 = $runrows ['lang_spoken3'];
            $lang_spoken4 = $runrows ['lang_spoken4'];
            $lang_spoken5 = $runrows ['lang_spoken5'];
            $lang_spoken6 = $runrows ['lang_spoken6'];
            $edu1 = $runrows ['edu1'];
            $edu2 = $runrows ['edu2'];
            $edu3 = $runrows ['edu3'];
            $edu4 = $runrows ['edu4'];
            $edu5 = $runrows ['edu5'];
            $edu6 = $runrows ['edu6'];
            $edu7 = $runrows ['edu7'];
            $edu8 = $runrows ['edu8'];
            $edu9 = $runrows ['edu9'];
            $edu10 = $runrows ['edu10'];
            $qualifications1 = $runrows ['qualifications1'];
            $qualifications2 = $runrows ['qualifications2'];
            $qualifications3 = $runrows ['qualifications3'];
            $qualifications4 = $runrows ['qualifications4'];
            $qualifications5 = $runrows ['qualifications5'];
            $qualifications6 = $runrows ['qualifications6'];
            $qualifications7 = $runrows ['qualifications7'];
            $qualifications8 = $runrows ['qualifications8'];
            $qualifications9 = $runrows ['qualifications9'];
            $qualifications10 = $runrows ['qualifications10'];
            $org_name1 = $runrows ['org_name1'];
            $org_name2 = $runrows ['org_name2'];
            $org_name3 = $runrows ['org_name3'];
            $org_name4 = $runrows ['org_name4'];
            $org_name5 = $runrows ['org_name5'];
            $pos_held1 = $runrows ['pos_held1'];
            $pos_held2 = $runrows ['pos_held2'];
            $pos_held3 = $runrows ['pos_held3'];
            $pos_held4 = $runrows ['pos_held4'];
            $pos_held5 = $runrows ['pos_held5'];
            $work_yoe1 = $runrows['work_yoe1'];
            $work_yoe2 = $runrows['work_yoe2'];
            $work_yoe3 = $runrows['work_yoe3'];
            $work_yoe4 = $runrows['work_yoe4'];
            $work_yoe5 = $runrows['work_yoe5'];
            $work_yoem1 = $runrows['work_yoem1'];
            $work_yoem2 = $runrows['work_yoem2'];
            $work_yoem3 = $runrows['work_yoem3'];
            $work_yoem4 = $runrows['work_yoem4'];
            $work_yoem5 = $runrows['work_yoem5'];
            $achievements = $runrows ['achievements'];
            $hobbies = $runrows ['hobbies'];
                                            
                                            
                                    echo "<h5>CV<b>$id</b></h5><br>";
                                    echo "<b>Gender</b>: $gender<br><br>";
                                    echo "<b>About</b> : $about<br><br>";
                                    echo "<b>Nationality</b>: $nationality<br><br>";
                                    echo "<b>Marital_status</b>: $marital_status<br><br>";
                                    echo "<b>Languages spoken</b>: $lang_spoken<br><br>";
                                    echo "<b>Job Wanted</b> :$job_type<br><br>";
                                    echo "<b>Qualifications </b>: $qualifications1<br><br>";
                                    echo "<button type='button' class='btn btn-info btn-lg' data-toggle='modal' data-target='#myModal'>View more</button><br><hr>";

   
               
            
      
}
      
      
      
      
                        //Pagination Starts
                        echo "<center>";

                        $prev = $start - $per_page;
                        $next = $start + $per_page;

                        $adjacents = 3;
                        $last = $max_pages - 1;

                        if($max_pages > 1)
                        {  
                        //previous button
                        if (!($start<=0))
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$prev'>Prev</a> ";    

                        //pages
                        if ($max_pages < 7 + ($adjacents * 2))   //not enough pages to bother breaking it up
                        {
                        $i = 0;  
                        for ($counter = 1; $counter <= $max_pages; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
                        }  
                        $i = $i + $per_page;                
                        }
                        }
                        elseif($max_pages > 5 + ($adjacents * 2))    //enough pages to hide some
                        {
                        //close to beginning; only hide later pages
                        if(($start/$per_page) < 1 + ($adjacents * 2))        
                        {
                        $i = 0;
                        for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search=$i'>$counter</a> ";
                        }
                        $i = $i + $per_page;                                      
                        }

                        }
                        //in middle; hide some front and some back
                        elseif($max_pages - ($adjacents * 2) > ($start / $per_page) && ($start / $per_page) > ($adjacents * 2))
                        {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

                        $i = $start;                
                        for ($counter = ($start/$per_page)+1; $counter < ($start / $per_page) + $adjacents + 2; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
                        }  
                        $i = $i + $per_page;                
                        }

                        }
                        //close to end; only hide early pages
                        else
                        {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

                        $i = $start;                
                        for ($counter = ($start / $per_page) + 1; $counter <= $max_pages; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";  
                        }
                        $i = $i + $per_page;              
                        }
                        }
                        }

                        //next button
                        if (!($start >=$foundnum-$per_page))
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$next'>Next</a> ";    
                        }  
                        echo "</center>";
                        }
                        }
?>






Here is what i have done but the pagination is not working
After code using mysqli

<?php
$button = $_GET [ 'submit' ];
$search = $_GET [ 'search' ];
if( !$button )
          echo "you didn't submit a keyword";
else {
    if( strlen( $search ) <= 1 )
            echo "Search term too short";
            else { echo "You searched for <b> $search </b> <hr size='1' > </ br > ";
            $conn = mysqli_connect( "localhost","root","",'register') ;
            $search_exploded = explode ( " ", $search );
            $x = 0;
            foreach( $search_exploded as $search_each ) {
                  $x++; $construct = "";
                  if( $x == 1 )
                                
                            $construct .="keyword LIKE '%$search_each%' OR qualifications1 LIKE '%$search_each%' OR dept LIKE '%$search_each%' ";
                           else
                                       $construct .="AND keyword LIKE '%$search_each%' OR AND qualifications1 LIKE '%$search_each%' OR AND dept LIKE '%$search_each%' ";
                        
          }
          $construct = " SELECT * FROM users WHERE $construct ";
          $run = $conn->query( $construct ); $foundnum = $run->num_rows ;
          if ($foundnum == 0)
                  echo "Sorry, there are no matching result for <b> $search </b>. </br> </br> 1. Try more keywords. for example: If you want to search 'For a person in the Banking Department' then use general keyword like 'Banking','Business','Finance' or if the person needed resides in the Information  technology Department, then use general keyword like 'I.T' ,'Information, technology','Informatics' etc. <br> </br> 2. Try different words with similar  meaning </br><br> 3. Please check your spelling";
                         
                  else {
                  echo "$foundnum results found !<p>";
                                $per_page = 1;
                                    $start = isset($_GET['start']) ? $_GET['start']: '';
                                    $max_pages = ceil($foundnum / $per_page);
                                    if(!$start)
                                    $start=0;
                                      $getquery = mysqli_query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");
                                
              while( $runrows = mysqli_fetch_assoc( $run ) ) {
                                
                       $id=$runrows['id'];
                                    $firstname = $runrows ['firstname'];
                                    $job_type = $runrows ['job_type'];
                                    $about = $runrows ['about'];
                                    $dept = $runrows ['dept'];
                                    $gender = $runrows ['gender'];
                                    $nationality = $runrows ['nationality'];
                                    $marital_status = $runrows ['marital_status'];
                                    $computer_literate = $runrows ['computer_literate'];
                                    $computer_literate2 = $runrows ['computer_literate2'];
                                    $computer_literate3 = $runrows ['computer_literate3'];
                                    $computer_literate4 = $runrows ['computer_literate4'];
                                    $computer_literate5 = $runrows ['computer_literate5'];
                                    $computer_literate6 = $runrows ['computer_literate6'];
                                    $computer_literate7 = $runrows ['computer_literate7'];
                                    $computer_literate8 = $runrows ['computer_literate8'];
                                    $computer_literate9 = $runrows ['computer_literate9'];
                                    $lang_spoken = $runrows ['lang_spoken'];
                                    $lang_spoken2 = $runrows ['lang_spoken2'];
                                    $lang_spoken3 = $runrows ['lang_spoken3'];
                                    $lang_spoken4 = $runrows ['lang_spoken4'];
                                    $lang_spoken5 = $runrows ['lang_spoken5'];
                                    $lang_spoken6 = $runrows ['lang_spoken6'];
                                    $edu1 = $runrows ['edu1'];
                                    $edu2 = $runrows ['edu2'];
                                    $edu3 = $runrows ['edu3'];
                                    $edu4 = $runrows ['edu4'];
                                    $edu5 = $runrows ['edu5'];
                                    $edu6 = $runrows ['edu6'];
                                    $edu7 = $runrows ['edu7'];
                                    $edu8 = $runrows ['edu8'];
                                    $edu9 = $runrows ['edu9'];
                                    $edu10 = $runrows ['edu10'];
                                    $qualifications1 = $runrows ['qualifications1'];
                                    $qualifications2 = $runrows ['qualifications2'];
                                    $qualifications3 = $runrows ['qualifications3'];
                                    $qualifications4 = $runrows ['qualifications4'];
                                    $qualifications5 = $runrows ['qualifications5'];
                                    $qualifications6 = $runrows ['qualifications6'];
                                    $qualifications7 = $runrows ['qualifications7'];
                                    $qualifications8 = $runrows ['qualifications8'];
                                    $qualifications9 = $runrows ['qualifications9'];
                                    $qualifications10 = $runrows ['qualifications10'];
                                    $org_name1 = $runrows ['org_name1'];
                                    $org_name2 = $runrows ['org_name2'];
                                    $org_name3 = $runrows ['org_name3'];
                                    $org_name4 = $runrows ['org_name4'];
                                    $org_name5 = $runrows ['org_name5'];
                                    $pos_held1 = $runrows ['pos_held1'];
                                    $pos_held2 = $runrows ['pos_held2'];
                                    $pos_held3 = $runrows ['pos_held3'];
                                    $pos_held4 = $runrows ['pos_held4'];
                                    $pos_held5 = $runrows ['pos_held5'];
                                    $work_yoe1 = $runrows['work_yoe1'];
                                    $work_yoe2 = $runrows['work_yoe2'];
                                    $work_yoe3 = $runrows['work_yoe3'];
                                    $work_yoe4 = $runrows['work_yoe4'];
                                    $work_yoe5 = $runrows['work_yoe5'];
                                    $work_yoem1 = $runrows['work_yoem1'];
                                    $work_yoem2 = $runrows['work_yoem2'];
                                    $work_yoem3 = $runrows['work_yoem3'];
                                    $work_yoem4 = $runrows['work_yoem4'];
                                    $work_yoem5 = $runrows['work_yoem5'];
                                    $achievements = $runrows ['achievements'];
                                    $hobbies = $runrows ['hobbies'];

                                            
                                       echo "<h5>CV<b>$id</b></h5><br>";
                                          echo "<b>Gender</b>: $gender<br><br>";
                                          echo "<b>About</b> : $about<br><br>";
                                          echo "<b>Nationality</b>: $nationality<br><br>";
                                          echo "<b>Marital_status</b>: $marital_status<br><br>";
                                          echo "<b>Languages spoken</b>: $lang_spoken<br><br>";
                                          echo "<b>Job Wanted</b> :$job_type<br><br>";
                                          echo "<b>Qualifications </b>: $qualifications1<br><br>";
                                          echo "<button type='button' class='btn btn-info btn-lg' data-toggle='modal' data-target='#myModal'>View more</button><br><hr>";
                        }
                                
                 
                         
                        //Pagination Starts
                        echo "<center>";

                        $prev = $start - $per_page;
                        $next = $start + $per_page;

                        $adjacents = 3;
                        $last = $max_pages - 1;

                        if($max_pages > 1)
                        {  
                        //previous button
                        if (!($start<=0))
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$prev'>Prev</a> ";    

                        //pages
                        if ($max_pages < 7 + ($adjacents * 2))   //not enough pages to bother breaking it up
                        {
                        $i = 0;  
                        for ($counter = 1; $counter <= $max_pages; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
                        }  
                        $i = $i + $per_page;                
                        }
                        }
                        elseif($max_pages > 5 + ($adjacents * 2))    //enough pages to hide some
                        {
                        //close to beginning; only hide later pages
                        if(($start/$per_page) < 1 + ($adjacents * 2))        
                        {
                        $i = 0;
                        for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search=$i'>$counter</a> ";
                        }
                        $i = $i + $per_page;                                      
                        }

                        }
                        //in middle; hide some front and some back
                        elseif($max_pages - ($adjacents * 2) > ($start / $per_page) && ($start / $per_page) > ($adjacents * 2))
                        {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

                        $i = $start;                
                        for ($counter = ($start/$per_page)+1; $counter < ($start / $per_page) + $adjacents + 2; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
                        }  
                        $i = $i + $per_page;                
                        }

                        }
                        //close to end; only hide early pages
                        else
                        {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

                        $i = $start;                
                        for ($counter = ($start / $per_page) + 1; $counter <= $max_pages; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";  
                        }
                        $i = $i + $per_page;              
                        }
                        }
                        }

                        //next button
                        if (!($start >=$foundnum-$per_page))
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$next'>Next</a> ";    
                        }  
                        echo "</center>";
                        }
                        }
}
            
            
                  ?>
Abraham Augustus NorteyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Off Topic #1 - PHP-5.6 is last version to support mysql_*() API calls, so come Jan 2019, when PHP-5.6 reaches EOL, you code won't work on PHP-7.x versions. Best tool to use the new mysqli_*() API, else you'll have much code to rewrite.

Off Topic #2 - Look into FTS (Full Text Search) indexes, to simplify your lookups.

Generally your code looks correct.

If I understand your question, I think you're saying your code works with mysql_*() calls + fails with mysqli_*() calls.

First, place a comment to clarify if my guess is correct or you're asking some other question.

Second, sigh... your code has no error checking, so there's no clue as to what the problem might be.

Tip: When you're developing code, first write your logging subsystem + trap/report every error which might occur.

So, go back into your code + add error trapping/reporting to every mysql API call.

The update your question with the exact error being returned from your database calls. Likely, the error will be self explanatory + you'll know instantly what to fix.
0
Abraham Augustus NorteyAuthor Commented:
Thank for replying to my  question , the code is working when  i enter a keywork, i get results alright but the pagination is not working again as compared to the first code i stated,I have limited it to i results per page but am getting all results displayed even with the pagination script



            
            

<?php
$button = $_GET [ 'submit' ];
$search = $_GET [ 'search' ];
if( !$button )
          echo "you didn't submit a keyword";
else {
    if( strlen( $search ) <= 1 )
            echo "Search term too short";
            else { echo "You searched for <b> $search </b> <hr size='1' > </ br > ";
            $conn = mysqli_connect( "localhost","root","",'register') ;
            $search_exploded = explode ( " ", $search );
            $x = 0;
            foreach( $search_exploded as $search_each ) {
                  $x++; $construct = "";
                  if( $x == 1 )
                                
                            $construct .="keyword LIKE '%$search_each%' OR qualifications1 LIKE '%$search_each%' OR dept LIKE '%$search_each%' ";
                           else
                                       $construct .="AND keyword LIKE '%$search_each%' OR AND qualifications1 LIKE '%$search_each%' OR AND dept LIKE '%$search_each%' ";
                        
          }
          $construct = " SELECT * FROM users WHERE $construct ";
          $run = $conn->query( $construct ); $foundnum = $run->num_rows ;
          if ($foundnum == 0)
                  echo "Sorry, there are no matching result for <b> $search </b>. </br> </br> 1. Try more keywords. for example: If you want to search 'For a person in the Banking Department' then use general keyword like 'Banking','Business','Finance' or if the person needed resides in the Information  technology Department, then use general keyword like 'I.T' ,'Information, technology','Informatics' etc. <br> </br> 2. Try different words with similar  meaning </br><br> 3. Please check your spelling";
                         
                  else {
                  echo "$foundnum results found !<p>";
                              
                                
                                
              while( $runrows = mysqli_fetch_assoc( $run ) ) {
                                
                       $id=$runrows['id'];
                                    $firstname = $runrows ['firstname'];
                                    $job_type = $runrows ['job_type'];
                                    $about = $runrows ['about'];
                                    $dept = $runrows ['dept'];
                                    $gender = $runrows ['gender'];
                                    $nationality = $runrows ['nationality'];
                                    $marital_status = $runrows ['marital_status'];
                                    $computer_literate = $runrows ['computer_literate'];
                                    $computer_literate2 = $runrows ['computer_literate2'];
                                    $computer_literate3 = $runrows ['computer_literate3'];
                                    $computer_literate4 = $runrows ['computer_literate4'];
                                    $computer_literate5 = $runrows ['computer_literate5'];
                                    $computer_literate6 = $runrows ['computer_literate6'];
                                    $computer_literate7 = $runrows ['computer_literate7'];
                                    $computer_literate8 = $runrows ['computer_literate8'];
                                    $computer_literate9 = $runrows ['computer_literate9'];
                                    $lang_spoken = $runrows ['lang_spoken'];
                                    $lang_spoken2 = $runrows ['lang_spoken2'];
                                    $lang_spoken3 = $runrows ['lang_spoken3'];
                                    $lang_spoken4 = $runrows ['lang_spoken4'];
                                    $lang_spoken5 = $runrows ['lang_spoken5'];
                                    $lang_spoken6 = $runrows ['lang_spoken6'];
                                    $edu1 = $runrows ['edu1'];
                                    $edu2 = $runrows ['edu2'];
                                    $edu3 = $runrows ['edu3'];
                                    $edu4 = $runrows ['edu4'];
                                    $edu5 = $runrows ['edu5'];
                                    $edu6 = $runrows ['edu6'];
                                    $edu7 = $runrows ['edu7'];
                                    $edu8 = $runrows ['edu8'];
                                    $edu9 = $runrows ['edu9'];
                                    $edu10 = $runrows ['edu10'];
                                    $qualifications1 = $runrows ['qualifications1'];
                                    $qualifications2 = $runrows ['qualifications2'];
                                    $qualifications3 = $runrows ['qualifications3'];
                                    $qualifications4 = $runrows ['qualifications4'];
                                    $qualifications5 = $runrows ['qualifications5'];
                                    $qualifications6 = $runrows ['qualifications6'];
                                    $qualifications7 = $runrows ['qualifications7'];
                                    $qualifications8 = $runrows ['qualifications8'];
                                    $qualifications9 = $runrows ['qualifications9'];
                                    $qualifications10 = $runrows ['qualifications10'];
                                    $org_name1 = $runrows ['org_name1'];
                                    $org_name2 = $runrows ['org_name2'];
                                    $org_name3 = $runrows ['org_name3'];
                                    $org_name4 = $runrows ['org_name4'];
                                    $org_name5 = $runrows ['org_name5'];
                                    $pos_held1 = $runrows ['pos_held1'];
                                    $pos_held2 = $runrows ['pos_held2'];
                                    $pos_held3 = $runrows ['pos_held3'];
                                    $pos_held4 = $runrows ['pos_held4'];
                                    $pos_held5 = $runrows ['pos_held5'];
                                    $work_yoe1 = $runrows['work_yoe1'];
                                    $work_yoe2 = $runrows['work_yoe2'];
                                    $work_yoe3 = $runrows['work_yoe3'];
                                    $work_yoe4 = $runrows['work_yoe4'];
                                    $work_yoe5 = $runrows['work_yoe5'];
                                    $work_yoem1 = $runrows['work_yoem1'];
                                    $work_yoem2 = $runrows['work_yoem2'];
                                    $work_yoem3 = $runrows['work_yoem3'];
                                    $work_yoem4 = $runrows['work_yoem4'];
                                    $work_yoem5 = $runrows['work_yoem5'];
                                    $achievements = $runrows ['achievements'];
                                    $hobbies = $runrows ['hobbies'];

                                            
                                       echo "<h5>CV<b>$id</b></h5><br>";
                                          echo "<b>Gender</b>: $gender<br><br>";
                                          echo "<b>About</b> : $about<br><br>";
                                          echo "<b>Nationality</b>: $nationality<br><br>";
                                          echo "<b>Marital_status</b>: $marital_status<br><br>";
                                          echo "<b>Languages spoken</b>: $lang_spoken<br><br>";
                                          echo "<b>Job Wanted</b> :$job_type<br><br>";
                                          echo "<b>Qualifications </b>: $qualifications1<br><br>";
                                          echo "<button type='button' class='btn btn-info btn-lg' data-toggle='modal' data-target='#myModal'>View more</button><br><hr>";
                        }
0
Abraham Augustus NorteyAuthor Commented:
This is how it looks like if its working
Screenshot--94-.png
Screenshot--95-.png
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Abraham Augustus NorteyAuthor Commented:
this is the one i did when i tried changing the database to mysqli which works well without the pagination


            
            

<?php
$button = $_GET [ 'submit' ];
$search = $_GET [ 'search' ];
if( !$button )
          echo "you didn't submit a keyword";
else {
    if( strlen( $search ) <= 1 )
            echo "Search term too short";
            else { echo "You searched for <b> $search </b> <hr size='1' > </ br > ";
            $conn = mysqli_connect( "localhost","root","",'register') ;
            $search_exploded = explode ( " ", $search );
            $x = 0;
            foreach( $search_exploded as $search_each ) {
                  $x++; $construct = "";
                  if( $x == 1 )
                                
                            $construct .="keyword LIKE '%$search_each%' OR qualifications1 LIKE '%$search_each%' OR dept LIKE '%$search_each%' ";
                           else
                                       $construct .="AND keyword LIKE '%$search_each%' OR AND qualifications1 LIKE '%$search_each%' OR AND dept LIKE '%$search_each%' ";
                        
          }
          $construct = " SELECT * FROM users WHERE $construct ";
          $run = $conn->query( $construct ); $foundnum = $run->num_rows ;
          if ($foundnum == 0)
                  echo "Sorry, there are no matching result for <b> $search </b>. </br> </br> 1. Try more keywords. for example: If you want to search 'For a person in the Banking Department' then use general keyword like 'Banking','Business','Finance' or if the person needed resides in the Information  technology Department, then use general keyword like 'I.T' ,'Information, technology','Informatics' etc. <br> </br> 2. Try different words with similar  meaning </br><br> 3. Please check your spelling";
                         
                  else {
                  echo "$foundnum results found !<p>";
                                $per_page = 1;
                                    $start = isset($_GET['start']) ? $_GET['start']: '';
                                    $max_pages = ceil($foundnum / $per_page);
                                    if(!$start)
                                    $start=0;
                                      $getquery = mysqli_query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");
                                
                                
              while( $runrows = mysqli_fetch_assoc( $run ) ) {
                                
                       $id=$runrows['id'];
                                    $firstname = $runrows ['firstname'];
                                    $job_type = $runrows ['job_type'];
                                    $about = $runrows ['about'];
                                    $dept = $runrows ['dept'];
                                    $gender = $runrows ['gender'];
                                    $nationality = $runrows ['nationality'];
                                    $marital_status = $runrows ['marital_status'];
                                    $computer_literate = $runrows ['computer_literate'];
                                    $computer_literate2 = $runrows ['computer_literate2'];
                                    $computer_literate3 = $runrows ['computer_literate3'];
                                    $computer_literate4 = $runrows ['computer_literate4'];
                                    $computer_literate5 = $runrows ['computer_literate5'];
                                    $computer_literate6 = $runrows ['computer_literate6'];
                                    $computer_literate7 = $runrows ['computer_literate7'];
                                    $computer_literate8 = $runrows ['computer_literate8'];
                                    $computer_literate9 = $runrows ['computer_literate9'];
                                    $lang_spoken = $runrows ['lang_spoken'];
                                    $lang_spoken2 = $runrows ['lang_spoken2'];
                                    $lang_spoken3 = $runrows ['lang_spoken3'];
                                    $lang_spoken4 = $runrows ['lang_spoken4'];
                                    $lang_spoken5 = $runrows ['lang_spoken5'];
                                    $lang_spoken6 = $runrows ['lang_spoken6'];
                                    $edu1 = $runrows ['edu1'];
                                    $edu2 = $runrows ['edu2'];
                                    $edu3 = $runrows ['edu3'];
                                    $edu4 = $runrows ['edu4'];
                                    $edu5 = $runrows ['edu5'];
                                    $edu6 = $runrows ['edu6'];
                                    $edu7 = $runrows ['edu7'];
                                    $edu8 = $runrows ['edu8'];
                                    $edu9 = $runrows ['edu9'];
                                    $edu10 = $runrows ['edu10'];
                                    $qualifications1 = $runrows ['qualifications1'];
                                    $qualifications2 = $runrows ['qualifications2'];
                                    $qualifications3 = $runrows ['qualifications3'];
                                    $qualifications4 = $runrows ['qualifications4'];
                                    $qualifications5 = $runrows ['qualifications5'];
                                    $qualifications6 = $runrows ['qualifications6'];
                                    $qualifications7 = $runrows ['qualifications7'];
                                    $qualifications8 = $runrows ['qualifications8'];
                                    $qualifications9 = $runrows ['qualifications9'];
                                    $qualifications10 = $runrows ['qualifications10'];
                                    $org_name1 = $runrows ['org_name1'];
                                    $org_name2 = $runrows ['org_name2'];
                                    $org_name3 = $runrows ['org_name3'];
                                    $org_name4 = $runrows ['org_name4'];
                                    $org_name5 = $runrows ['org_name5'];
                                    $pos_held1 = $runrows ['pos_held1'];
                                    $pos_held2 = $runrows ['pos_held2'];
                                    $pos_held3 = $runrows ['pos_held3'];
                                    $pos_held4 = $runrows ['pos_held4'];
                                    $pos_held5 = $runrows ['pos_held5'];
                                    $work_yoe1 = $runrows['work_yoe1'];
                                    $work_yoe2 = $runrows['work_yoe2'];
                                    $work_yoe3 = $runrows['work_yoe3'];
                                    $work_yoe4 = $runrows['work_yoe4'];
                                    $work_yoe5 = $runrows['work_yoe5'];
                                    $work_yoem1 = $runrows['work_yoem1'];
                                    $work_yoem2 = $runrows['work_yoem2'];
                                    $work_yoem3 = $runrows['work_yoem3'];
                                    $work_yoem4 = $runrows['work_yoem4'];
                                    $work_yoem5 = $runrows['work_yoem5'];
                                    $achievements = $runrows ['achievements'];
                                    $hobbies = $runrows ['hobbies'];

                                            
                                       echo "<h5>CV<b>$id</b></h5><br>";
                                          echo "<b>Gender</b>: $gender<br><br>";
                                          echo "<b>About</b> : $about<br><br>";
                                          echo "<b>Nationality</b>: $nationality<br><br>";
                                          echo "<b>Marital_status</b>: $marital_status<br><br>";
                                          echo "<b>Languages spoken</b>: $lang_spoken<br><br>";
                                          echo "<b>Job Wanted</b> :$job_type<br><br>";
                                          echo "<b>Qualifications </b>: $qualifications1<br><br>";
                                          echo "<button type='button' class='btn btn-info btn-lg' data-toggle='modal' data-target='#myModal'>View more</button><br><hr>";
                        }
                                
                 
                         
                        //Pagination Starts
                        echo "<center>";

                        $prev = $start - $per_page;
                        $next = $start + $per_page;

                        $adjacents = 3;
                        $last = $max_pages - 1;

                        if($max_pages > 1)
                        {  
                        //previous button
                        if (!($start<=0))
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$prev'>Prev</a> ";    

                        //pages
                        if ($max_pages < 7 + ($adjacents * 2))   //not enough pages to bother breaking it up
                        {
                        $i = 0;  
                        for ($counter = 1; $counter <= $max_pages; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
                        }  
                        $i = $i + $per_page;                
                        }
                        }
                        elseif($max_pages > 5 + ($adjacents * 2))    //enough pages to hide some
                        {
                        //close to beginning; only hide later pages
                        if(($start/$per_page) < 1 + ($adjacents * 2))        
                        {
                        $i = 0;
                        for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search=$i'>$counter</a> ";
                        }
                        $i = $i + $per_page;                                      
                        }

                        }
                        //in middle; hide some front and some back
                        elseif($max_pages - ($adjacents * 2) > ($start / $per_page) && ($start / $per_page) > ($adjacents * 2))
                        {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

                        $i = $start;                
                        for ($counter = ($start/$per_page)+1; $counter < ($start / $per_page) + $adjacents + 2; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
                        }  
                        $i = $i + $per_page;                
                        }

                        }
                        //close to end; only hide early pages
                        else
                        {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

                        $i = $start;                
                        for ($counter = ($start / $per_page) + 1; $counter <= $max_pages; $counter++)
                        {
                        if ($i == $start){
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
                        }
                        else {
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";  
                        }
                        $i = $i + $per_page;              
                        }
                        }
                        }

                        //next button
                        if (!($start >=$foundnum-$per_page))
                        echo " <a href='searchResult.php?search=$search&submit=Search&start=$next'>Next</a> ";    
                        }  
                        echo "</center>";
                        }
                        }
}
            
            
                  ?>
0
Chris StanyonWebDevCommented:
Hey Abraham,

The reason you're seeing all the results even with the pagination is because you're looping through the first query (the one without the LIMIT clause), rather than the second one (the one with the LIMIT clause:

// Query to get the number of rows
$construct = " SELECT * FROM users WHERE $construct ";
$run = $conn->query( $construct );

// Query to LIMIT the results 
$getquery = mysqli_query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");
while( $runrows = mysqli_fetch_assoc( $run ) ) { 

Open in new window

That last line is looping the first query ($run) instead of the second query ($getquery). It should be:

while( $runrows = mysqli_fetch_assoc( $getquery ) ) { 

Open in new window

0
Abraham Augustus NorteyAuthor Commented:
Thanks for the reply Chris but after effecting the changes , am getting another error

This is what i did (Image of error attached below)

<?php
$button = $_GET [ 'submit' ];
$search = $_GET [ 'search' ];
if( !$button )
          echo "you didn't submit a keyword";
else {
    if( strlen( $search ) <= 1 )
            echo "Search term too short";
            else { echo "You searched for <b> $search </b> <hr size='1' > </ br > ";
            $conn = mysqli_connect( "localhost","root","",'register') ;
            $search_exploded = explode ( " ", $search );
            $x = 0;
            foreach( $search_exploded as $search_each ) {
                  $x++; $construct = "";
                  if( $x == 1 )
                                
                            $construct .="keyword LIKE '%$search_each%' OR qualifications1 LIKE '%$search_each%' OR dept LIKE '%$search_each%' ";
                           else
                                       $construct .="AND keyword LIKE '%$search_each%' OR AND qualifications1 LIKE '%$search_each%' OR AND dept LIKE '%$search_each%' ";
                        
          }
          $construct = " SELECT * FROM users WHERE $construct ";
          $run = $conn->query( $construct ); $foundnum = $run->num_rows ;
          if ($foundnum == 0)
                  echo "Sorry, there are no matching result for <b> $search </b>. </br> </br> 1. Try more keywords. for example: If you want to search 'For a person in the Banking Department' then use general keyword like 'Banking','Business','Finance' or if the person needed resides in the Information  technology Department, then use general keyword like 'I.T' ,'Information, technology','Informatics' etc. <br> </br> 2. Try different words with similar  meaning </br><br> 3. Please check your spelling";
                         
                  else {
                  echo "$foundnum results found !<p>";
                               $per_page = 1;
                              $start = isset($_GET['start']) ? $_GET['start']: '';
                              $max_pages = ceil($foundnum / $per_page);
                              if(!$start)
                              $start=0;
                              $getquery = mysqli_query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");
                                
                                while( $runrows = mysqli_fetch_assoc( $getquery ) ) {
Screenshot--97-.png
0
Chris StanyonWebDevCommented:
Hi Abraham,

You're now trying to use the old and deprecated mysql* functions instead of the newer mysqli* functions (notice the i in the function name). You're also mixing procedural functions and object oriented functions, so I would suggest you standardise and go with the OOP way.  The last lines of the code you posted should look like this:

$getquery = $conn->query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");
while( $runrows = $getquery->fetch_assoc() ) {

Open in new window

0
Abraham Augustus NorteyAuthor Commented:
Hello Chris, still am getting a different type of error
image to the error below..thanks

<?php
$button = $_GET [ 'submit' ];
$search = $_GET [ 'search' ];
if( !$button )
          echo "you didn't submit a keyword";
else {
    if( strlen( $search ) <= 1 )
            echo "Search term too short";
            else { echo "You searched for <b> $search </b> <hr size='1' > </ br > ";
            $conn = mysqli_connect( "localhost","root","",'register') ;
            $search_exploded = explode ( " ", $search );
            $x = 0;
            foreach( $search_exploded as $search_each ) {
                  $x++; $construct = "";
                  if( $x == 1 )
					  
                      	$construct .="keyword LIKE '%$search_each%' OR qualifications1 LIKE '%$search_each%' OR dept LIKE '%$search_each%' ";
                           else
					   	$construct .="AND keyword LIKE '%$search_each%' OR AND qualifications1 LIKE '%$search_each%' OR AND dept LIKE '%$search_each%' ";
				
          }
          $construct = " SELECT * FROM users WHERE $construct ";
          $run = $conn->query( $construct ); $foundnum = $run->num_rows ;
          if ($foundnum == 0) 
                  echo "Sorry, there are no matching result for <b> $search </b>. </br> </br> 1. Try more keywords. for example: If you want to search 'For a person in the Banking Department' then use general keyword like 'Banking','Business','Finance' or if the person needed resides in the Information  technology Department, then use general keyword like 'I.T' ,'Information, technology','Informatics' etc. <br> </br> 2. Try different words with similar  meaning </br><br> 3. Please check your spelling"; 
				  
                  else {
                  echo "$foundnum results found !<p>";
					 $per_page = 1;
					$start = isset($_GET['start']) ? $_GET['start']: '';
					$max_pages = ceil($foundnum / $per_page);
					if(!$start)
					$start=0; 
				
							$getquery = $conn->query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");
							while( $runrows = $getquery->fetch_assoc() ) {
					  
                       $id=$runrows['id'];
						$firstname = $runrows ['firstname'];
						$job_type = $runrows ['job_type'];
						$about = $runrows ['about'];
						$dept = $runrows ['dept'];
						$gender = $runrows ['gender'];
						$nationality = $runrows ['nationality'];
						$marital_status = $runrows ['marital_status'];
						$computer_literate = $runrows ['computer_literate'];
						$computer_literate2 = $runrows ['computer_literate2'];
						$computer_literate3 = $runrows ['computer_literate3'];
						$computer_literate4 = $runrows ['computer_literate4'];
						$computer_literate5 = $runrows ['computer_literate5'];
						$computer_literate6 = $runrows ['computer_literate6'];
						$computer_literate7 = $runrows ['computer_literate7'];
						$computer_literate8 = $runrows ['computer_literate8'];
						$computer_literate9 = $runrows ['computer_literate9'];
						$lang_spoken = $runrows ['lang_spoken'];
						$lang_spoken2 = $runrows ['lang_spoken2'];
						$lang_spoken3 = $runrows ['lang_spoken3'];
						$lang_spoken4 = $runrows ['lang_spoken4'];
						$lang_spoken5 = $runrows ['lang_spoken5'];
						$lang_spoken6 = $runrows ['lang_spoken6'];
						$edu1 = $runrows ['edu1'];
						$edu2 = $runrows ['edu2'];
						$edu3 = $runrows ['edu3'];
						$edu4 = $runrows ['edu4'];
						$edu5 = $runrows ['edu5'];
						$edu6 = $runrows ['edu6'];
						$edu7 = $runrows ['edu7'];
						$edu8 = $runrows ['edu8'];
						$edu9 = $runrows ['edu9'];
						$edu10 = $runrows ['edu10'];
						$qualifications1 = $runrows ['qualifications1'];
						$qualifications2 = $runrows ['qualifications2'];
						$qualifications3 = $runrows ['qualifications3'];
						$qualifications4 = $runrows ['qualifications4'];
						$qualifications5 = $runrows ['qualifications5'];
						$qualifications6 = $runrows ['qualifications6'];
						$qualifications7 = $runrows ['qualifications7'];
						$qualifications8 = $runrows ['qualifications8'];
						$qualifications9 = $runrows ['qualifications9'];
						$qualifications10 = $runrows ['qualifications10'];
						$org_name1 = $runrows ['org_name1'];
						$org_name2 = $runrows ['org_name2'];
						$org_name3 = $runrows ['org_name3'];
						$org_name4 = $runrows ['org_name4'];
						$org_name5 = $runrows ['org_name5'];
						$pos_held1 = $runrows ['pos_held1'];
						$pos_held2 = $runrows ['pos_held2'];
						$pos_held3 = $runrows ['pos_held3'];
						$pos_held4 = $runrows ['pos_held4'];
						$pos_held5 = $runrows ['pos_held5'];
						$work_yoe1 = $runrows['work_yoe1'];
						$work_yoe2 = $runrows['work_yoe2'];
						$work_yoe3 = $runrows['work_yoe3'];
						$work_yoe4 = $runrows['work_yoe4'];
						$work_yoe5 = $runrows['work_yoe5'];
						$work_yoem1 = $runrows['work_yoem1'];
						$work_yoem2 = $runrows['work_yoem2'];
						$work_yoem3 = $runrows['work_yoem3'];
						$work_yoem4 = $runrows['work_yoem4'];
						$work_yoem5 = $runrows['work_yoem5'];
						$achievements = $runrows ['achievements'];
						$hobbies = $runrows ['hobbies'];

							   
						   echo "<h5>CV<b>$id</b></h5><br>";
							echo "<b>Gender</b>: $gender<br><br>";
							echo "<b>About</b> : $about<br><br>";
							echo "<b>Nationality</b>: $nationality<br><br>";
							echo "<b>Marital_status</b>: $marital_status<br><br>";
							echo "<b>Languages spoken</b>: $lang_spoken<br><br>";
							echo "<b>Job Wanted</b> :$job_type<br><br>";
							echo "<b>Qualifications </b>: $qualifications1<br><br>";
							echo "<button type='button' class='btn btn-info btn-lg' data-toggle='modal' data-target='#myModal'>View more</button><br><hr>";
                     }
					  
				//Pagination Starts
				echo "<center>";

				$prev = $start - $per_page;
				$next = $start + $per_page;

				$adjacents = 3;
				$last = $max_pages - 1;

				if($max_pages > 1)
				{   
				//previous button
				if (!($start<=0)) 
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$prev'>Prev</a> ";    

				//pages 
				if ($max_pages < 7 + ($adjacents * 2))   //not enough pages to bother breaking it up
				{
				$i = 0;   
				for ($counter = 1; $counter <= $max_pages; $counter++)
				{
				if ($i == $start){
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
				}
				else {
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
				}  
				$i = $i + $per_page;                 
				}
				}
				elseif($max_pages > 5 + ($adjacents * 2))    //enough pages to hide some
				{
				//close to beginning; only hide later pages
				if(($start/$per_page) < 1 + ($adjacents * 2))        
				{
				$i = 0;
				for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
				{
				if ($i == $start){
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
				}
				else {
				echo " <a href='searchResult.php?search=$search&submit=Search=$i'>$counter</a> ";
				} 
				$i = $i + $per_page;                                       
				}

				}
				//in middle; hide some front and some back
				elseif($max_pages - ($adjacents * 2) > ($start / $per_page) && ($start / $per_page) > ($adjacents * 2))
				{
				echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

				$i = $start;                 
				for ($counter = ($start/$per_page)+1; $counter < ($start / $per_page) + $adjacents + 2; $counter++)
				{
				if ($i == $start){
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
				}
				else {
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";
				}   
				$i = $i + $per_page;                
				}

				}
				//close to end; only hide early pages
				else
				{
				echo " <a href='searchResult.php?search=$search&submit=Search&start=0'>1</a> ";
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$per_page'>2</a> .... ";

				$i = $start;                
				for ($counter = ($start / $per_page) + 1; $counter <= $max_pages; $counter++)
				{
				if ($i == $start){
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'><b>$counter</b></a> ";
				}
				else {
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$i'>$counter</a> ";   
				} 
				$i = $i + $per_page;              
				}
				}
				}

				//next button
				if (!($start >=$foundnum-$per_page))
				echo " <a href='searchResult.php?search=$search&submit=Search&start=$next'>Next</a> ";    
				}  
					  
				echo "</center>";
                  }
              }
            } 
				
		
		
                  ?>

Open in new window

Screenshot--99-.png
0
Chris StanyonWebDevCommented:
Hey Abraham,

When you post code in your question, can you wrap it in the code tags from the menu. It makes it a lot easier to read, as we can refer to line numbers. I've edited your previous comment so you can see what I mean.

Now the error you're receiving is because your call on line 35 failed. If you look through your code above on line 22, you have this:

$construct = " SELECT * FROM users WHERE $construct ";

And then on line 35 you have this:

$getquery = $conn->query("SELECT * FROM users WHERE $construct LIMIT $start, $per_page");

So the query you're actually trying to run on line 35 ends up looking like this:

SELECT * FROM users WHERE SELECT * FROM users WHERE $construct LIMIT $start, $per_page");

Your line 35 should look like this:

$getquery = $conn->query("$construct LIMIT $start, $per_page");
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Abraham Augustus NorteyAuthor Commented:
Hello Dave and Chris ,am highly grateful for the help u offered.It works now .Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.