Displaying some selected search results through a modal

I created a search engine and is displaying results from the  database and beneath the results is a bootstrap modal for which am displaying some selected results in there
Problem is that i want to for each results fetched eg row 1 of id 1 should displayed the contents for id 1 and not any other but here in this if  3 results is found, it displays the 3rd  results for all which shouldn't be the case.
Beneath is an images that shows the above...Any help to solve this is highly appreciated.




<?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("$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>";
                  }
              }
            } 
				
		
		
                  ?>
	
	
	
		
</div>
	
	</div>
	</div>
	

	<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">
<div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title" align="center">Extra Details</h4><br>
		   <h5 class="modal-title" align="center" style="color: green;"><?php echo "<b>You are viewing  some details of </b>CV$id </b>";  ?></h5><hr>
	    <ul style="color: red;"><b>
		     
        </ul></b>
      </div>
      <div class="modal-body">
       <div>
		   <div id="printTable">
		 <?php
	 			
				
			echo "<h5>CV<b>$id</b></h5>";
			echo "<b>About Entry</b>: $about<br><br><br>";
		   echo "<b>Department</b>: $dept<br><br><br><br>";
		   echo "<b>Gender</b>: $gender<br><br><br><br>";
		   echo "<b>Nationality</b>: $nationality<br><br><br><br>";
		   echo "<b>Marital_status</b>: $marital_status<br><br><br><br>";
		   echo "<b>Computer Background</b>:<br><br>";
		   
		   echo "$computer_literate<br><br><br>"; 
		   echo "$computer_literate2 <br><br><br>";
		    echo "$computer_literate3<br><br><br>";
		    echo "$computer_literate4 <br><br><br>";
		   echo " $computer_literate5<br><br><br>"; 
		   echo " $computer_literate6 <br>";
		   echo "<b>Languages spoken</b><br>"; 
		   echo " $lang_spoken-";
		   echo " $lang_spoken2-";
		   echo " $lang_spoken3-";
		   echo " $lang_spoken4-";
		   echo " $lang_spoken5-";
		   echo " $lang_spoken6<br><br><br><br>";
		   echo "<b>Educational Background</b>:<br><br> $edu1 <br><b>Qualification</b>: $qualifications1<br><br><br>";
			    echo " $edu2 <br><b>Qualification</b>:$qualifications2<br><br><br>"; 
			   echo " $edu3 <br><b>Qualification</b>:$qualifications3<br><br><br>";
			   echo " $edu4 <br><b>Qualification</b>:$qualifications4<br><br><br>";
			   echo "<b>Working Experience</b>:<br><br> $org_name1 <br><b>Position held</b>: $pos_held1<br><b>Experience</b>: $work_yoe1 $work_yoem1<br><br><br>";
			   echo " $org_name2 <br><b>Qualification</b>:$pos_held2<br><b>Experience</b>: $work_yoe2 $work_yoem2<br><br><br>"; 
			   echo " $org_name3 <br><b>Qualification</b>:$pos_held3<br><b>Experience</b>: $work_yoe3 $work_yoem3<br><br><br>";
			   echo " $org_name4 <br><b>Qualification</b>:$pos_held4<br><b>Experience</b>: $work_yoe4 $work_yoem4<br><br><br><br>";
		   echo "<b>Job Type Wanted</b> :$job_type<br><br><br><br>";
		  echo "<b>Other Relevant Achievements</b> :$achievements<br><br><br><br>";
		 
		   echo "<b>Hobbies</b>: $hobbies<br><br><br><br>";
		
								
 ?>
		  </div>
      </div>
      <div class="modal-footer">
    <!--<button type='button' class='btn btn-info btn-md' data-toggle='modal' data-target='#Contact_Modal'>Pay</button>-->
		  <a href="#contactModal" role="button" data-toggle="modal" style="width:150px"; class="btn btn-primary">Pay</a>
		
		    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>  
		 
		  <span class="glyphicon glyphicon-print"></span> <a href="#null" onclick="printContent('printTable')">Print Cv</a>
		 
				<script>
		  
		  </script>	
<script type="text/javascript">
function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open('','printwin','left=100,top=100,width=1000,height=1000')
newwin.document.write('<HTML>\n<HEAD>\n')
newwin.document.write('<TITLE>Print Page</TITLE>\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="print_win()">\n')
newwin.document.write(str)
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
newwin.document.close()
}

</script>
   
	

      </div>
    </div>

  </div>
</div>

Open in new window

Screenshot--100-.png
Screenshot--101-.png
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.

Chris StanyonWebDevCommented:
Hi Abraham,

OK, firstly an explanation of what's going on. You're selecting several records from the DB and then looping through them:

while( $runrows = $getquery->fetch_assoc() ) {
    $id=$runrows['id'];
    $firstname = $runrows ['firstname'];
    ...
}

Open in new window

Now each time you loop through the records, you are overwriting the variables ($id / $firstname). By the time you've finished the loop, those variables will only hold the values from the last record in the loop.

You need a way to retreive the relevant information for each user when you want to show the Modal, and to do this you have a couple of options.

You could store each record in a data-attribute, for example on the button. You can then retrieve all the info for a specific user when you click on each button, and use that info to populate the Modal before showing it. Alternatively, you could just store the ID in the button and then make an AJAX request back to the server to retreive the full user details from the database as and when you need it.

Both ways have their pros and cons. The first way would need you to retrieve and manipulate the data using Javascript (preferably jQuery as it's easier), but all the data would be readily available. The second method would make building the Modal slightly easier, but would require an extra round-trip to the server to retrieve the User Info (and an extra php script). Personally, I prefer the second (AJAX) approach, but it's up to you.

Let me know which method you want to look at and I'll give you some pointers.
0
Abraham Augustus NorteyAuthor Commented:
Okay Lets see the Ajax approach, although i must state that my java script knowledge is at the beginners level.
0
Chris StanyonWebDevCommented:
Haha. No worries. We'll work through it together. I think the best thing to do is to give a very simple example before you try and integrate it into your own solution because there are several moving parts. Firstly, create a separate file for your DB Connection. Call it something simple like db.php

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

$hostname = 'localhost';
$username = 'username';
$password = 'password';
$database = 'database';

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

try  {
    $db = new mysqli($hostname, $username, $password, $database);
    $db->set_charset("utf8");
} catch (mysqli_sql_exception $e) {
    die( $e->getMessage() );
}

Open in new window

Next create the file that will display the summary information:

<?php require_once 'db.php'; ?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Chris Stanyon</title>
        <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
        <script>
        $(function() {
            $('.moreInfo').click(function() {
                $.post('getUser.php', { id : $(this).data('id') }, function(response) {
                    $('#details').html(response);
                }, 'html');
            });
        });
        </script>   
    </head>
    <body>

        <?php $users = $db->query("SELECT id, firstname FROM members"); ?>

        <?php while ($user = $users->fetch_object()): ?>
            <div class="user">
                <h1><?= $user->firstname ?></h1>
                <button class="moreInfo" data-id="<?= $user->id ?>">Get More Info</button>
            </div>
        <?php endwhile; ?>

        <div id="details"></div>

    </body>
</html>

Open in new window

All we're doing here is selecting the ID and Firstname from a members table. You'll notice in the loop that we create a button for Get More Info, and on that button we're creating a data attribute called id - we're storing the ID of the user in there so we can use it to retrieve the full details. If you look at the jQuery script, you can see that when the button (.moreinfo) is clicked, we send the user id back to a script (an AJAX request) on the server called getUser.php, and whatever that script outputs will be dropped into the #details div. In your app, it would be the Modal form.

Finally, you need to create the server-side getUser.php script:

<?php
if (!isset($_POST['id'])) die("No User Specified");

// Connect to the Database
require_once 'db.php';

try {
    // Prepare and execute the query
    $query = $db->prepare("SELECT firstname, lastname, email FROM members WHERE id = ? LIMIT 1");
    $query->bind_param("i", $_POST['id']);
    $query->execute();

    // Get the results
    $users = $query->get_result();

    // Try and retrieve the record
    if ( ! $user = $users->fetch_object() ) die("No User Found");
    
} catch (Exception $e) {

    die($e->getMessage());

}
?>

<h1><?= $user->firstname ?></h1>
<p>Fullname: <?= $user->firstname ?> <?= $user->lastname ?></p>
<p>Email: <a href="mailto:<?= $user->email ?>"><?= $user->email ?></a></p>

Open in new window

This script is passed the ID as part of the POST array, just like a normal form. It then queries the database for a record matching that ID, and builds an HTML response. This response is then sent back to the calling page, where it will be dropped into the #details div.

Have a go at creating the 3 files and you'll start to see how the AJAX system works.
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Abraham Augustus NorteyAuthor Commented:
Am done Sir,  db.php , Summ.php and getUser.php
[b]db.php[/b]




<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

$hostname = 'localhost';
$username = 'root';
$password = '';
$database = 'register';

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

try  {
    $db = new mysqli($hostname, $username, $password, $database);
    $db->set_charset("utf8");
} catch (mysqli_sql_exception $e) {
    die( $e->getMessage() );
}




[b]Summ.php[/b]



<?php require_once 'db.php'; ?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Modal Display</title>
        <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
			<!--<script src="jquery/jquery-3.1.0.min.js"></script>-->
        <script>
        $(function() {
            $('.moreInfo').click(function() {
                $.post('getUser.php', { id : $(this).data('id') }, function(response) {
                    $('#details').html(response);
                }, 'html');
            });
        });
        </script>   
    </head>
    <body>

        <?php $users = $db->query("SELECT id, firstname FROM users"); ?>

        <?php while ($user = $users->fetch_object()): ?>
            <div class="user">
                <h1><?= $user->firstname ?></h1>
                <button class="moreInfo" data-id="<?= $user->id ?>">Get More Info</button>
            </div>
        <?php endwhile; ?>

        <div id="details"></div>

    </body>
</html>



[b]getUser.php[/b]



<?php
if (!isset($_POST['id'])) die("No User Specified");

// Connect to the Database
require_once 'db.php';

try {
    // Prepare and execute the query
    $query = $db->prepare("SELECT firstname, lastname, email FROM users WHERE id = ? LIMIT 1");
    $query->bind_param("i", $_POST['id']);
    $query->execute();

    // Get the results
    $users = $query->get_result();

    // Try and retrieve the record
    if ( ! $user = $users->fetch_object() ) die("No User Found");
    
} catch (Exception $e) {

    die($e->getMessage());

}
?>

<h1><?= $user->firstname ?></h1>
<p>Fullname: <?= $user->firstname ?> <?= $user->lastname ?></p>
<p>Email: <a href="mailto:<?= $user->email ?>"><?= $user->email ?></a></p>

Open in new window

0
Chris StanyonWebDevCommented:
OK.

Did it work as expected?
Did you understand the all the code and what each part does?
Have you tried to integrate this into your own code?

I would suggest you try to put this into action on your own site and then come back if you get any problems or have any further questions.
0
Abraham Augustus NorteyAuthor Commented:
Did you understand the all the code and what each part does? yes i understand but the problem i have is how to integrate this into my code to display with search results
this i understands goes to  the head section
<script>
        $(function() {
            $('.moreInfo').click(function() {
                $.post('getUser.php', { id : $(this).data('id') }, function(response) {
                    $('#details').html(response);
                }, 'html');
            });
        });
        </script>   
    </head>

Open in new window

   
<body>

        <?php $users = $db->query("SELECT id, firstname FROM members"); ?>

        <?php while ($user = $users->fetch_object()): ?>
            <div class="user">
                <h1><?= $user->firstname ?></h1>
                <button class="moreInfo" data-id="<?= $user->id ?>">Get More Info</button>
            </div>

Open in new window

0
Abraham Augustus NorteyAuthor Commented:
This script will only come into play only when is the button is pressed which in my case is the modal button

<?php
if (!isset($_POST['id'])) die("No User Specified");

// Connect to the Database
require_once 'db.php';

try {
    // Prepare and execute the query
    $query = $db->prepare("SELECT firstname, lastname, email FROM members WHERE id = ? LIMIT 1");
    $query->bind_param("i", $_POST['id']);
    $query->execute();

    // Get the results
    $users = $query->get_result();

    // Try and retrieve the record
    if ( ! $user = $users->fetch_object() ) die("No User Found");
    
} catch (Exception $e) {

    die($e->getMessage());

}
?>

<h1><?= $user->firstname ?></h1>
<p>Fullname: <?= $user->firstname ?> <?= $user->lastname ?></p>
<p>Email: <a href="mailto:<?= $user->email ?>"><?= $user->email ?></a></p>

Open in new window

0
Abraham Augustus NorteyAuthor Commented:
If u can elaborate a little with respect to my app which being the search results
<body>

        <?php $users = $db->query("SELECT id, firstname FROM members"); ?>

        <?php while ($user = $users->fetch_object()): ?>
            <div class="user">
                <h1><?= $user->firstname ?></h1>
                <button class="moreInfo" data-id="<?= $user->id ?>">Get More Info</button>
            </div>
        <?php endwhile; ?>

        <div id="details"></div>

    </body>

Open in new window

0
Chris StanyonWebDevCommented:
Right. In your code, you need to output the HTML that shows the summary:

while ($runrows = $getquery->fetch_object()):
    echo "<h5>CV<b>{$runrows->id}</b></h5><br>";
    echo "<b>Gender</b>: {$runrows->gender}<br><br>";
    echo "<b>About</b>: {$runrows->about}<br><br>";
    echo "<b>Nationality</b>: {$runrows->nationality}<br><br>";
    echo "<b>Marital_status</b>: {$runrows->marital_status}<br><br>";
    echo "<b>Languages spoken</b>: {$runrows->lang_spoken}<br><br>";
    echo "<b>Job Wanted</b>: {$runrows->job_type}<br><br>";
    echo "<b>Qualifications</b>: {$runrows->qualifications1}<br><br>";
    echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='{$runrows->id}'>View more</button><br><hr>";
endwhile;

Open in new window

And then you need to add the jQuery to your document to retrieve the user's information. The result of that call needs dropping into your modal, which will contain the empty #printTable element::

<div class="modal-body">
<div>
    <div id="printTable"></div>
</div>

Open in new window

So the jQuery needs to drop the content into the #printTable element, and also fire the modal, so it will look like this:

<script>
$(function() {
    $('.more-info').click(function() {
        $.post('getUser.php', { id : $(this).data('id') }, function(response) {
            $('#printTable').html(response);
            $('#myModal').modal('show');
        }, 'html');
    });
});
</script>

Open in new window

0
Abraham Augustus NorteyAuthor Commented:
Thanks for the feedback, will try it and let you know the outcome.
0
Abraham Augustus NorteyAuthor Commented:
Hello Chris, This is what i did,
First i added the getUser.php script and db.php to the search page,This is what happened
1. the search page becomes blank when i add the getUser.php
2.Without the getUser i got an error..Will post images below
<?php
include_once 'getUser.php';
require_once 'config/db.php';
include_once 'partials/parseRequest.php';
?>

Open in new window



Then i added this script to the header
    
<script>
$(function() {
    $('.more-info').click(function() {
        $.post('getUser.php', { id : $(this).data('id') }, function(response) {
            $('#printTable').html(response);
            $('#myModal').modal('show');
        }, 'html');
    });
});
</script>

Open in new window


Then echoed the button to display with the results
	echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='{$runrows->id}'>View more</button><br><hr>";

Open in new window



And in my modal
<div class="modal-body">
       <div>
		   <div id="printTable">
		  <?php $users = $db->query("SELECT id, firstname FROM users"); ?>

        <?php while ($user = $users->fetch_object()): ?>
           
        <?php endwhile; ?>
		  </div>
      </div>

Open in new window

Screenshot--105-.png
Screenshot--104-.png
0
Chris StanyonWebDevCommented:
OK,

You don't need to add the getUser.php script to the search page. That's just a standalone file as per my previous example.

Your Modal needs an EMPTY #printTable div (re-read my previous comment).

The idea is that you output all the summary information for your search results, and each of these summaries has a button that contains the ID of the user from the search results. Then when you click on that button, an AJAX request is made to getUser.php script, passing in the ID. That script then does a DB query to retrieve that user and returns the information. It then drops that information into the Modal and shows it.
0
Abraham Augustus NorteyAuthor Commented:
Ok. i understand ..But after effecting the changes, the error message still persits
Screenshot--104-.png
0
Chris StanyonWebDevCommented:
OK. You'll need to show me what you have on line 168. Might make more sense to post your whole page.
0
Abraham Augustus NorteyAuthor Commented:
I had comments in there so i took them off,Its now line 148

<?php
$page_title = "Search";
include_once 'partials/headsearch-before.php';
include_once 'partials/parseRequest.php';

?>
 


<div class="container">
    <section class="col col-lg-6"><br><br><br><br><br><br>
    <h3>Search Results</h3><hr>

		<form action='searchResult.php' method ='GET'>
                   <input type = 'text' size='90' name = 'search' value="<?php echo $_GET['search']?>">
                           
                          <input type = 'submit' name = 'submit' value = 'Search' class="btn btn-primary" >
            </form>  
		<br>
		 <?php if(isset($result)) echo $result; ?>
		</div>
      
<br>
<div class="container-fluid" >
<div class="row jumbotron">
	<!--<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9 col-xl-10">   --->
    <div class="col-12">
    <p class="lead"> 
   
		
			
		
		

<?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 = 3;
					$start = isset($_GET['start']) ? $_GET['start']: '';
					$max_pages = ceil($foundnum / $per_page);
					if(!$start)
					$start=0; 
							$getquery = $conn->query("$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 more-info' data-id='{$runrows->id}'>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>";
                  }
              }
            } 
				
		
		
                  ?>
	
	
	
		
</div>
	
	</div>
	</div>
	

	<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">
<div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title" align="center">Extra Details</h4><br>
		   <h5 class="modal-title" align="center" style="color: green;"><?php echo "<b>You are viewing  some details of </b>CV$id </b>";  ?></h5><hr>
	    <ul style="color: red;"><b>
		    
        </ul></b>
      </div>
	
      <div class="modal-body">
       <div>
		   <div id="printTable">
		  
		  </div>
      </div>
      <div class="modal-footer">
    <!--<button type='button' class='btn btn-info btn-md' data-toggle='modal' data-target='#Contact_Modal'>Pay</button>-->
		  <a href="#contactModal" role="button" data-toggle="modal" style="width:150px"; class="btn btn-primary">Pay</a>
		
		    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>  
		 
		  <span class="glyphicon glyphicon-print"></span> <a href="#null" onclick="printContent('printTable')">Print Cv</a>
		 
				<script>
		  
		  </script>	
<script type="text/javascript">
function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open('','printwin','left=100,top=100,width=1000,height=1000')
newwin.document.write('<HTML>\n<HEAD>\n')
newwin.document.write('<TITLE>Print Page</TITLE>\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="print_win()">\n')
newwin.document.write(str)
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
newwin.document.close()
}

</script>
   
	

      </div>
    </div>

  </div>
</div>
	

   


 <!--Modal -->
        <div id="contactModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="contactModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title">Payment form</h4>
                    </div>
					  <div>
            <?php if(isset($result)) echo $result; ?>
            <?php if(!empty($form_errors)) echo show_errors($form_errors); ?>
        </div>
                    <div class="modal-body">
                        <div class="containter">
                            <div class="row">
                               <form class="form-horizontal" action="" method="post">   <!--Request-sucess.php-->
                                    <div class="col-xs-8">
                                       
                                       
                                          <div class="form-group">
                        <label for="id"><b>Subject ID</b></label>
                        <input type="text" name="sid" value="CV<?php echo $id ?>" class="form-control" id="sid" required>
                    </div>
               <div class="form-group">
                 <label for="poc"><b>Person/Company</b></label>
                   <input name="poc" type="text" required class="form-control" id="poc" placeholder="Person or Company name" >
                 </div>
				
										
										 <div class="form-group">
		    <div class="dropdown" >
                        <label for="mop" ><b>Mode of payment</b></label>    
                       
                <select name="mop" id="mop" class="form-control" onclick='test()'>
					 <option value="a">--SELECT--</option>
<option value="Mobile Money">Mobile Money Transfer</option>
  <option value="Bank">Cv Bureau Bank Account</option>
</select>
				<select id="DC" name="DC" style="display: none">
    <option value="Mtn Momo">Mtn Momo</option>
    <option value="Airtel Money">Airtel Money</option>
    <option value="Tigo Cash">Tigo Cash</option>
    <option value="Vodafone Cash">Vodafone Cash</option>
</select>
				
				<select id="BP" name="BP" style="display: none">
    <option value="1">ECOxxxxxxxx124568</option>
    
</select>
											 </div>
										</div>
			
			
						        				 
				
			<script>
				function test() {
    if (document.getElementById('mop').value == 'Mobile Money') {
        document.getElementById('DC').style.display = 'block';
    } else {
        document.getElementById('DC').style.display = 'none';
    }
}
	</script>	
										
									
										 <div class="form-group">
                        <label for="Telephone Contact">Telephone Contact</label> <br>            
                        <input type="tel" id="hp" name="tel" value="" class="form-control" required>
                       

	<script src="js/jquery.min.js"></script>
	<script src="js/intlTelInput.js"></script>
	<script src="js/defaultCountryIp.js"></script>
	<script>
	$('#hp').intlTelInput({
		initialCountry: "auto",
		geoIpLookup: function(callback){
			
			$.get('http://ipinfo.io', function(){}, "jsonp").always(function(resp){
				
				var countryCode = (resp && resp.country) ? resp.country : "";
				callback(countryCode);
			
				
			});
		},
		

		

allowExtensions: true,
autoFormat: false,
autoHideDialCode: false,
autoPlaceholder: false,
defaultCountry: "auto",
ipinfoToken: "yolo",
nationalMode: false,
numberType: "MOBILE",
//onlyCountries: ['us', 'gb', 'ch', 'ca', 'do'],
//preferredCountries: ['cn', 'jp'],
preventInvalidNumbers: true,
		utilsScript: "js/utils.js"
	});
	</script>
										</div>
			   <div class="form-group">
                 <label for="email"><b>Email</b></label>
                       <input name="email" type="email" required class="form-control" id="email" placeholder="Enter email address" >
                   </div>	
				
				<div class="form-group">
					 <label for="message"><b>Message</b></label>
                                         
                                            <div class="col-lg-8">
                                                <textarea name="message" id="message" class="form-control" rows="5" required></textarea>
                                            </div>
                                        </div>
										
				<div class="form-group">
					 <div class="col-lg-8">
				<div class="g-recaptcha" data-sitekey="6Lf0cFkUAAAAAMkBgyiR7v0CaRTdFxyjzjfHZceC" align="center"></div>
										</div>					
										</div>					
										
										 <input type="hidden" name="token" value="<?php if(function_exists('_token')) echo _token(); ?>">
          <button type="submit" name="signupBtn" class="btn btn-warning">Send <span class="glyphicon glyphicon-send"></span></button>
										
                                      
                                    </div>
									
                                </form>
									
                                <hr class="featurette-divider hidden-lg">
					      </div>
                                

                        

                        </div>
                    </div><!-- End of Modal body -->
                </div><!-- End of Modal content -->
            </div><!-- End of Modal dialog -->
        </div><!-- End of Modal -->




      <!---<p style="color:green;">This page belongs to <?php if(isset($_SESSION['username'])) echo $_SESSION['username']; ?> including every data/information present,were submitted by <?php if(isset($_SESSION['username'])) echo $_SESSION['username']; ?>. Feel free to update and make changes to the information.</p>
      <br>
        <div>
            <?php if(isset($result)) echo $result; ?>
            <?php if(!empty($form_errors)) echo show_errors($form_errors); ?>
        </div>
        <div class="clearfix"></div>

        <?php if(!isset($_SESSION['username'])): ?>
            <P class="lead">You are not authorized to view this page <a href="login.php">Login</a>
                Not yet a member? <a href="signup.php">Signup</a> </P>
        <?php else: ?>--->
		
		<!--Code-->
              
        
		
        <?php endif ?>
    </section>
    
</div>
<?php include_once 'partials/footers.php'; ?>
</body>
</html>

Open in new window

Screenshot--106-.png
0
Chris StanyonWebDevCommented:
OK. Well that code doesn't look anything like the code I posted !!

Change line 148 to use $id indead of $runrows->id

echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='$id'>View more</button><br><hr>";

Open in new window

If you code it like I posted, then lines 73-136 are not needed.
0
Abraham Augustus NorteyAuthor Commented:
The Error message is gone but the modal wont open
Screenshot--107-.png
0
Abraham Augustus NorteyAuthor Commented:
I get an error message, If i format it like you stated.Image below

while( $runrows = $getquery->fetch_assoc() ) {
					  
                     
    echo "<h5>CV<b>{$runrows->id}</b></h5><br>";
    echo "<b>Gender</b>: {$runrows->gender}<br><br>";
    echo "<b>About</b>: {$runrows->about}<br><br>";
    echo "<b>Nationality</b>: {$runrows->nationality}<br><br>";
    echo "<b>Marital_status</b>: {$runrows->marital_status}<br><br>";
    echo "<b>Languages spoken</b>: {$runrows->lang_spoken}<br><br>";
    echo "<b>Job Wanted</b>: {$runrows->job_type}<br><br>";
    echo "<b>Qualifications</b>: {$runrows->qualifications1}<br><br>";
	echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='$id'>View more</button><br><hr>";

                     }

Open in new window

Screenshot--109-.png
0
Chris StanyonWebDevCommented:
Yeah - that's not what I posted. The first line needs to fetch an object not as assoc:

while ($runrows = $getquery->fetch_object()):

And if you go this route, you need to change the $id in the button back to $runrows->id, like in the code I've already posted.

As for your Modal not working - the screenshot doesn't tell me anything.

You will need to open up your Developer Console (press F12 on your keyboard), and then check the Console tab. See if there are any errors in there when you click the Buttons.

Do you have this site on a live link that I can take a look at.
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:
1. Do you have this site on a live link that I can take a look at?  Unless Team viewer and i can inbox you the details if its possible

As for Errors there are none
0
Abraham Augustus NorteyAuthor Commented:
Chris, it seems the search engine stopped working as expected,After going through this way i
while ($runrows = $getquery->fetch_object()):
    echo "<h5>CV<b>{$runrows->id}</b></h5><br>";
    echo "<b>Gender</b>: {$runrows->gender}<br><br>";
    echo "<b>About</b>: {$runrows->about}<br><br>";
    echo "<b>Nationality</b>: {$runrows->nationality}<br><br>";
    echo "<b>Marital_status</b>: {$runrows->marital_status}<br><br>";
    echo "<b>Languages spoken</b>: {$runrows->lang_spoken}<br><br>";
    echo "<b>Job Wanted</b>: {$runrows->job_type}<br><br>";
    echo "<b>Qualifications</b>: {$runrows->qualifications1}<br><br>";
    echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='{$runrows->id}'>View more</button><br><hr>";
endwhile;

Open in new window



I realized that if I entered a keyword and i get the message 3 results foud,only two are displayed whiles pagination function is also absent
and if two results found, only one is display
But if i revert back to the original code It works, images posted below
while( $runrows = $getquery->fetch_assoc() ) {
					  
                       $id=$runrows['id'];
						$firstname = $runrows ['firstname'];
						$job_type = $runrows ['job_type'];
						$about = $runrows ['about'];


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>"

Open in new window

Screenshot--110-.png
Screenshot--111-.png
Screenshot--112-.png
Screenshot--113-.png
Screenshot--114-.png
0
Abraham Augustus NorteyAuthor Commented:
echo "$foundnum results found !<p>";
					 $per_page = 10;
					$start = isset($_GET['start']) ? $_GET['start']: '';
					$max_pages = ceil($foundnum / $per_page);
					if(!$start)
					$start=0; 
							$getquery = $conn->query("$construct LIMIT $start, $per_page"); 
					  
					  while ($runrows = $getquery->fetch_object()):
					  
						echo "<h5>CV<b>{$runrows->id}</b></h5><br>";
						echo "<b>Gender</b>: {$runrows->gender}<br><br>";
						echo "<b>About</b> : {$runrows->about}<br><br>";
						echo "<b>Nationality</b>: {$runrows->nationality}<br><br>";
						echo "<b>Marital_status</b>: {$runrows->marital_status}<br><br>";
						echo "<b>Languages spoken</b>: {$runrows->lang_spoken}<br><br>";
						echo "<b>Job Wanted</b> :{$runrows->job_type}<br><br>";
						echo "<b>Qualifications </b>: {$runrows->qualifications1}<br><br>";
						echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='{$runrows->id}'>View more</button><br><hr>";					  
					  
					  endwhile;

Open in new window

0
Abraham Augustus NorteyAuthor Commented:
Hi Chris , am extremely grateful for the time you dedicated to helping me fix the errors in my project. Forever Grateful
0
Chris StanyonWebDevCommented:
No worries Abraham :)
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
Query Syntax

From novice to tech pro — start learning today.