<?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">×</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>
Screenshot--100-.png<?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() );
}
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>
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.<?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>
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.[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>
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>
<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
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>
<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>
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;
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>
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>
<?php
include_once 'getUser.php';
require_once 'config/db.php';
include_once 'partials/parseRequest.php';
?>
<script>
$(function() {
$('.more-info').click(function() {
$.post('getUser.php', { id : $(this).data('id') }, function(response) {
$('#printTable').html(response);
$('#myModal').modal('show');
}, 'html');
});
});
</script>
echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='{$runrows->id}'>View more</button><br><hr>";
<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>
<?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">×</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>
echo "<button type='button' class='btn btn-info btn-lg more-info' data-id='$id'>View more</button><br><hr>";
If you code it like I posted, then lines 73-136 are not needed.
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>";
}
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;
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>"
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;
OK, firstly an explanation of what's going on. You're selecting several records from the DB and then looping through them:
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.