php page break after certain rows and repeat header on each page - javascript

Below is my code for display data on print preview..
In this table i need to repeat header on every page.
I need to print only 10 rows in each page..After that need page break and display Data data on next page With repeating header...
Now my prob. is my code repeat header after 10 rows but i cannot understand how to break page after 10 rows and header display on next page...not in middle of the page...
plz help me..
<td width="38%"><input type="submit" value="print" onClick="PrintDiv();" /></td>
<table border="1px solid #666" cellpadding='0' cellspacing='0'>
<thead>
<tr>
<th width="4%">Sr.No</th>
<th width="10%">Book / Recpt No</th>
<th width="7%">Booking Dt</th>
<th width="9%">Copy Start Dt</th>
<th width="14%">Surveyor Name</th>
<th width="18%">Customer</th>
<th width="27%">Coupon No</th>
<th width="5%">Price</th>
<th width="6%">Gift Del.</th>
</tr>
</thead>
<?php
$i=1;
$counter=1;
$pageCounter=1;
foreach($data as $row){
?>
<?php
if($counter==11)
{
$counter=1;
?>
<thead>
<tr class="breakAfter">
<th width="4%">Sr.No</th>
<th width="10%">Book / Recpt No</th>
<th width="7%">Booking Dt</th>
<th width="9%">Copy Start Dt</th>
<th width="14%">Surveyor Name</th>
<th width="18%">Customer</th>
<th width="27%">Coupon No</th>
<th width="5%">Price</th>
<th width="6%">Gift Del.</th>
</tr>
</thead>
<?php } ?>
<tbody>
<tr>
<td height="54"><?php echo $i; ?></td>
<td><?php echo htmlspecialchars($row['book_no']); ?> / <?php echo htmlspecialchars($row['receipt_no']); ?></td>
<td><?php echo htmlspecialchars($row['bookingdate']); ?></td>
<td><?php echo htmlspecialchars($row['startingdate']); ?></td>
<td><?php echo htmlspecialchars($row['surveyor_name']); ?></td>
<td><?php echo htmlspecialchars($row['prefix']); ?>,<?php echo htmlspecialchars($row['customer_name']); ?></td>
<td><?php echo htmlspecialchars($row['cou']); ?></td>
<td><?php echo htmlspecialchars($row['amount']); ?></td>
<td><?php echo htmlspecialchars($row['deliveredgift']); ?></td>
</tr>
<?php $counter++; $i++; }?>
</tbody>
</table>

Related

I want to add a color to the highest number in the column row on the table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 months ago.
Improve this question
Original Version
What I expect
I need to do my table like this but I don't know JavaScript and I need some help about that.
Numbers are always changing
They said it could be done with JavaScript or PHP, but I couldn't do it with php. Since I have no knowledge of JavaScript, I wanted to consult you.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="tr-TR">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="custom-table-responsive ">
<div class="text-center">
<div class="bg-light p-3 overflow-hidden rounded border shadow">
<div class="table-responsive">
<table class="table table-striped table-hover table-light mb-0 table-bordered">
<thead>
<tr>
<th style="width: 220px" rowspan="2" class="align-middle">
<div>TESTER</div>
</th>
<th colspan="2">
<div>Category 1</div>
</th>
<th colspan="2">
<div>Category 2</div>
</th>
<th colspan="2">
<div>Category 3</div>
</th>
<th colspan="2">
<div>Category 4</div>
</th>
</tr>
<tr>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
</tr>
</thead>
<tbody>
<tr>
<th class="table-left-seperator">TEST</th>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
</tr>
<tr>
<th class="table-left-seperator">TEST</th>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
</tr>
<tr>
<th class="table-left-seperator">TEST</th>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
</tr>
<tr>
<th class="table-left-seperator">TEST</th>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
<td><?php echo rand(100,1500); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
While SO isn't the place for getting people to do code for you, this was a fun challenge, so I couldn't help myself, sorry.
I agree that this should be done serverside for convenience (and maybe even for performance(?)), but here is a Javascript solution.
I hardcoded the random php values, but you can just replace all numbers again with <?php echo rand(100,1500); ?> or use your own (it will still work with your original php/html).
const tBody = document.querySelector("tbody");
const trs = tBody.querySelectorAll("tr");
const tds = tBody.querySelectorAll("td");
const numberOfColumns = tds.length / trs.length;
let isSellClm = true;
for (let clm = 0; clm < numberOfColumns; clm++) {
const highLow = {
value: isSellClm ? Infinity : 0,
element: null
};
for (let row = 0; row < trs.length; row++) {
const td = tds[row * numberOfColumns + clm];
const number = parseInt(td.textContent);
if (isSellClm) {
if (number < highLow.value) {
highLow.value = number,
highLow.element = td;
}
} else {
if (number > highLow.value) {
highLow.value = number,
highLow.element = td;
}
}
}
highLow.element.style.color = isSellClm ? "green" : "red";
isSellClm = !isSellClm;
}
<div class="container">
<div class="custom-table-responsive ">
<div class="text-center">
<div class="bg-light p-3 overflow-hidden rounded border shadow">
<div class="table-responsive">
<table class="table table-striped table-hover table-light mb-0 table-bordered">
<thead>
<tr>
<th style="width: 220px" rowspan="2" class="align-middle">
<div>TESTER</div>
</th>
<th colspan="2">
<div>
Category 1</div>
</th>
<th colspan="2">
<div>
Category 2</div>
</th>
<th colspan="2">
<div>
Category 3</div>
</th>
<th colspan="2">
<div>
Category 4</div>
</th>
</tr>
<tr>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
<th><span>Sell</span></th>
<th><span>Buy</span></th>
</tr>
</thead>
<tbody>
<tr>
<th class="table-left-seperator">TEST</th>
<td>398</td>
<td>510</td>
<td>359</td>
<td>809</td>
<td>1151</td>
<td>1123</td>
<td>787</td>
<td>1443</td>
</tr>
<tr>
<th class="table-left-seperator">TEST</th>
<td>549</td>
<td>1201</td>
<td>1112</td>
<td>1276</td>
<td>1440</td>
<td>177</td>
<td>822</td>
<td>218</td>
</tr>
<tr>
<th class="table-left-seperator">TEST</th>
<td>1278</td>
<td>701</td>
<td>797</td>
<td>194</td>
<td>403</td>
<td>477</td>
<td>1447</td>
<td>534</td>
</tr>
<tr>
<th class="table-left-seperator">TEST</th>
<td>712</td>
<td>1399</td>
<td>406</td>
<td>411</td>
<td>531</td>
<td>497</td>
<td>483</td>
<td>459</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
If you need the code to be more robust, you should give the queried elements an id or data-attribute or some other unique identifier and query that, eg.:
<tbody id="table-body">
const tBody = document.querySelector("#table-body");

How to delete from json table?

I have a table like below:
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Nazwa</th>
<th scope="col">Cena</th>
<th scope="col">Kupujący</th>
<th scope="col"> </th>
</tr>
</thead>
<tbody>
<?php foreach($data as $key => $value): ?>
<tr>
<td><?php echo $value['id']; ?></td>
<td><?php echo $value['name']; ?></td>
<td><?php echo $value['price']; ?></td>
<td><?php echo $value['buyer']; ?></td>
<td><button type="button" name="button2" >Usuń</button></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
how to delete item from this list via clicking on the button in last column of the table?
my php:
$jsonData = file_get_contents("data.json");
$data = json_decode($jsonData, true);
thanks for any help, I don't know how to get value by button clicking :/
It seems that your data is gotten from a file, so to get it done you need to go over all these steps in the same php script:
Get data from this file
Parse data with json_decode
Remove an item using unset($data['id'])
Save new data in the same file
Here is an example:
$jsonData = file_get_contents("data.json");
$data = json_decode($jsonData, true);
// here we go
if(isset($_POST['item_key']) && !empty($_POST['item_key'])) {
$data = array_values($data);
$i=0;
foreach($data as $element) {
//check if it's the right item
if(intval($_POST['item_key']) == $element['id']){ // intval only if you are sure id passed in POST[item_key] always integer
unset($data[$i]);
}
$i++;
}
file_put_contents('data.json', json_encode(array_values($data)));
}
$_POST['item_key'] will come after submiting the form in the html, see below.
In your html code, you will need to add the following:
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Nazwa</th>
<th scope="col">Cena</th>
<th scope="col">Kupujący</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php foreach($data as $key =>
$value): ?>
<tr>
<td><?php echo $value['id']; ?></td>
<td><?php echo $value['name']; ?></td>
<td><?php echo $value['price']; ?></td>
<td><?php echo $value['buyer']; ?></td>
<td>
<!-- action="#" means you will stay in the same script after submit -->
<form action="#" method="POST">
<input
hidden
type="text"
name="item_key"
value="<?php echo $value['id'];?>"
/>
<input type="submit" value="Remove" />
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
UPDATE
Used unset with array_values after json_decode
Removed header(refre..) since the refresh will be done by form submit to same script

How to add value in html table column

I am working on the following codes. I need to add all the values per category in my table. The data is from the database. Please see the picture first:
Here is my interface image
Here is my HTML codes:
<table id="data" class="table table-bordered table-striped">
<thead>
<tr align="center">
<th width="5%">Item</th>
<th width="30%">Description</th>
<th width="5%">Unit</th>
<th width="5%">Qty</th>
<th width="10%">Unit Cost</th>
<th width="15%">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td colspan="5"><i>General Requirement</i></td>
</tr>
<?php
$id = $_GET['id'];
$select_bill = "SELECT *, quantity * unit_cost AS amount FROM bill_tbl WHERE project_name = $id";
$select_bill_result = mysqli_query($con,$select_bill);
if (mysqli_num_rows($select_bill_result)> 0) {
while ($row = mysqli_fetch_assoc($select_bill_result)) {
if ($row['category'] == 'General Requirement') {
?>
<tr>
<td></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['unit']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['unit_cost']; ?></td>
<td><?php echo $row['amount']; ?></td>
</tr>
<?php
}
}
}
?>
<tr>
<td></td>
<td colspan="4"><b>Subtotal</b></td>
<td></td>
</tr>
<tr>
<td>2</td>
<td colspan="5"><i>Concrete and Masonry Works</i></td>
</tr>
<?php
$id = $_GET['id'];
$select_bill = "SELECT *, quantity * unit_cost AS amount FROM bill_tbl WHERE project_name = $id";
$select_bill_result = mysqli_query($con,$select_bill);
if (mysqli_num_rows($select_bill_result)> 0) {
while ($row = mysqli_fetch_assoc($select_bill_result)) {
if ($row['category'] == 'Concrete and Masonry Works') {
?>
<tr>
<td></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['unit']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['unit_cost']; ?></td>
<td><?php echo $row['amount']; ?></td>
</tr>
<?php
}
}
}
?>
<tr>
<td></td>
<td colspan="4"><b>Subtotal</b></td>
<td></td>
</tr>
</tbody>
</table>
Script code
<script>
var total = 0;
var rows = $("#data tr:gt(0)");
rows.children("td:nth-child(6)").each(function() {
total += parseInt($(this).html());
});
$("#total").html(total);
</script>
This is for my school project.
You can sum it at PHP part. Code like this will sum all amounts while retrieving from DB.
<table id="data" class="table table-bordered table-striped">
<thead>
<tr align="center">
<th width="5%">Item</th>
<th width="30%">Description</th>
<th width="5%">Unit</th>
<th width="5%">Qty</th>
<th width="10%">Unit Cost</th>
<th width="15%">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td colspan="5"><i>General Requirement</i></td>
</tr>
<?php
$id = $_GET['id'];
$select_bill = "SELECT *, quantity * unit_cost AS amount FROM bill_tbl WHERE project_name = $id";
$select_bill_result = mysqli_query($con,$select_bill);
if (mysqli_num_rows($select_bill_result)> 0) {
while ($row = mysqli_fetch_assoc($select_bill_result)) {
if ($row['category'] == 'General Requirement') {
$subtotal += $row['amount']; //Here you sum all amounts from rows
?>
<tr>
<td></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['unit']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['unit_cost']; ?></td>
<td><?php echo $row['amount']; ?></td>
</tr>
<?php
}
}
}
?>
<tr>
<td></td>
<td colspan="4"><b>Subtotal</b></td>
<td><?php echo $subtotal; //Here you display subtotal ?></td>
</tr>
<tr>
<td>2</td>
<td colspan="5"><i>Concrete and Masonry Works</i></td>
</tr>
<?php
$id = $_GET['id'];
$select_bill = "SELECT *, quantity * unit_cost AS amount FROM bill_tbl WHERE project_name = $id";
$select_bill_result = mysqli_query($con,$select_bill);
if (mysqli_num_rows($select_bill_result)> 0) {
while ($row = mysqli_fetch_assoc($select_bill_result)) {
if ($row['category'] == 'Concrete and Masonry Works') {
$subtotal += $row['amount']; //Here you sum all amounts from rows
?>
<tr>
<td></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['unit']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['unit_cost']; ?></td>
<td><?php echo $row['amount']; ?></td>
</tr>
<?php
}
}
}
?>
<tr>
<td></td>
<td colspan="4"><b>Subtotal</b></td>
<td><?php echo $subtotal; //Here you display subtotal ?></td>
</tr>
</tbody>
</table>
<table id="data" class="table table-bordered table-striped">
<thead>
<tr align="center">
<th width="5%">Item</th>
<th width="30%">Description</th>
<th width="5%">Unit</th>
<th width="5%">Qty</th>
<th width="10%">Unit Cost</th>
<th width="15%">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td colspan="5"><i>General Requirement</i></td>
</tr>
<?php
$id = $_GET['id']; $catA =0; //this variable will be use to get the some of the category. You can name the variable whatever name you want
$select_bill = "SELECT *, quantity * unit_cost AS amount FROM bill_tbl WHERE project_name = $id";
$select_bill_result = mysqli_query($con,$select_bill);
if (mysqli_num_rows($select_bill_result)> 0) {
while ($row = mysqli_fetch_assoc($select_bill_result)) {
if ($row['category'] == 'General Requirement') {
$catA+=$row['amount']; // this will add each amount value to the $catA variable until the loop finished;
?>
<tr>
<td></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['unit']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['unit_cost']; ?></td>
<td><?php echo $row['amount']; ?></td>
</tr>
<?php
}
}
}
?>
<tr>
<td></td>
<td colspan="4"><b>Subtotal</b></td>
<td><?php echo $catA; //the variable now has the total sum of the amount;?></td>
</tr>
<tr>
<td>2</td>
<td colspan="5"><i>Concrete and Masonry Works</i></td>
</tr>
<?php
$id = $_GET['id']; $catB =0; //this variable will be use to get the some of the category. You can name the variable whatever name you want
$select_bill = "SELECT *, quantity * unit_cost AS amount FROM bill_tbl WHERE project_name = $id";
$select_bill_result = mysqli_query($con,$select_bill);
if (mysqli_num_rows($select_bill_result)> 0) {
while ($row = mysqli_fetch_assoc($select_bill_result)) {
if ($row['category'] == 'Concrete and Masonry Works') {
$catB+=$row['amount']; // this will add the amount value to the $catB variable until the loop finished;
?>
<tr>
<td></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['unit']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo $row['unit_cost']; ?></td>
<td><?php echo $row['amount']; ?></td>
</tr>
<?php
}
}
}
?>
<tr>
<td></td>
<td colspan="4"><b>Subtotal</b></td>
<td><?php echo $catB; //the variable now has the total sum of the amount;?></td>
</tr>
</tbody>
</table>

How to hide the value in table and anchor tag when user click the anchor return

I want to hide the row when the admin click the anchor return because It's already saved in return.php so just need hide the returned status while the pending is not. Thank you for helping me
<thead>
<tr>
<th>Book title</th>
<th>Borrower</th>
<th>Type</th>
<th>Date Borrow</th>
<th>Due Date</th>
<th>Date Returned</th>
<th>Fines</th>
<th>Borrow Status</th>
</tr>
</thead>
<tbody>
<?php $user_query=mysqli_query($dbcon,"select * from borrow
LEFT JOIN member ON borrow.member_id = member.member_id
LEFT JOIN borrowdetails ON borrow.borrow_id = borrowdetails.borrow_id
LEFT JOIN book on borrowdetails.book_id = book.book_id
ORDER BY borrow.borrow_id DESC
")or die(mysqli_error());
while($row=mysqli_fetch_array($user_query)){
$currentdate = date('Y/m/d');
$start = new DateTime($returndate=$row['due_date']);
$end = new DateTime($currentdate);
$fines =0;
if(strtotime($currentdate) > strtotime($returndate)){
$days= $start->diff($end, true)->days;
$fines = $days > 0 ? intval(floor($days)) * 10 : 0;
$fi = $row['borrow_details_id'];
mysqli_query($dbcon,"update borrowdetails set fines='$fines' where borrow_details_id = '$fi'");
}
$id=$row['borrow_id'];
$book_id=$row['book_id'];
$borrow_details_id=$row['borrow_details_id'];
?>
<tr class="del<?php echo $id ?>">
<td><?php echo $row['book_title']; ?></td>
<td><?php echo $row['firstname']." ".$row['lastname']; ?></td>
<td><?php echo $row['type']; ?></td>
<td><?php echo $row['date_borrow']; ?></td>
<td><?php echo $row['due_date']; ?> </td>
<td><?php echo $row['date_return']; ?> </td>
<td><?php echo "₱ ".$fines; ?></td>
<td><?php echo $row['borrow_status'];?></td>
<td> <a rel="tooltip" title="Return" id="<?php echo $borrow_details_id; ?>"
href="#delete_book<?php echo $borrow_details_id; ?>" data-toggle="modal"
class="btn btn-success"><i class="icon-check icon-large"></i>Return</a>
<?php include('modal_return.php'); ?>
<td></td>
</tr>
<?php } ?>
</tbody>
</table>
This is the view_return.php where will admin see the all books pending
This is the history/transaction where the book is already return
For this , you can do like below example, Add a class "test" in anchorTag or in td
and by using jquery
$('.test').click(function(){
$(this).parent().hide();
});
<table>
<tr>
<td>Test</td>
<td class="test" id="returnId1">Return</td>
</tr>
<tr>
<td>Test2</td>
<td class="test" id="returnId2">Return</td>
</tr>
</table>

fetch view table values in another page while click on the button in codeigniter

i have one view candidates page in my application..in that page i display all the candidate details..in that page i gave one button called SCHEDULE INTERVIEW..when user click on the button i want to display that particular row candidates values in another page..i want to get only name and email of the particular candidate like:
Name:******
email:*******
like this i want to display that particular candidate details..
View page:
<div class="box-body">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th></th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Mobile Number</th>
<th>experience</th>
<th>CTC</th>
<th>Expected Ctc</th>
<th>role</th>
<th>Current Location</th>
<th>Desired Location</th>
<th>Notice Period</th>
<th>Resume</th>
<th>Actions</th>
</tr>
</thead>
<?php foreach ($view_candidates as $idata) { ?>
<tbody>
<tr id="domain<?php echo $idata->user_id;?>">
<td class="cell checkbox">
<input type="checkbox" class="selectedId" name="selectedId" />
</td>
<td><?php echo $idata->first_name;?></td>
<td><?php echo $idata->last_name;?></td>
<td><?php echo $idata->email;?></td>
<td><?php echo $idata->mobile_number;?></td>
<td><?php echo $idata->experience;?></td>
<td><?php echo $idata->ctc;?></td>
<td><?php echo $idata->expectedctc;?></td>
<td><?php echo $idata->role_name;?></td>
<td><?php echo $idata->current_location;?></td>
<td><?php echo $idata->desired_location;?></td>
<td><?php echo $idata->notice_period;?></td>
<td><?php echo $idata->resume;?></td>
<td>
Schedule interview
</td>
</tr>
</tbody>
Can anyone help me..
How to do this..
Thanks in Advance..
Something like below:
<?php
// controller
function candidate_detail($candidateid)
{
$data = $this->model_name->get_candidate_detail($candidateid);
$viewData['getCandidate'] = $data;
$this->load->view('candidate_view',$viewData);
}
// model
function get_candidate_detail($candidateid)
{
$q = $this->db->query("SELECT * FROM tbl_name WHERE candidate_id = $candidateid");
if($q->num_rows() > 0) {
return $q->row_array();
} else {
return '';
}
}
?>
// view candidate_view
<div class="box-body">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th></th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Mobile Number</th>
<th>experience</th>
<th>CTC</th>
<th>Expected Ctc</th>
<th>role</th>
<th>Current Location</th>
<th>Desired Location</th>
<th>Notice Period</th>
<th>Resume</th>
</tr>
</thead>
<tbody>
<tr id="domain<?php echo $getCandidate['user_id'];?>">
<td class="cell checkbox">
<input type="checkbox" class="selectedId" name="selectedId" />
</td>
<td><?php echo $getCandidate['first_name'];?></td>
<td><?php echo $getCandidate['last_name'];?></td>
<td><?php echo $getCandidate['email'];?></td>
<td><?php echo $getCandidate['mobile_number'];?></td>
<td><?php echo $getCandidate['experience'];?></td>
<td><?php echo $getCandidate['ctc'];?></td>
<td><?php echo $getCandidate['expectedctc'];?></td>
<td><?php echo $getCandidate['role_name'];?></td>
<td><?php echo $getCandidate['current_location'];?></td>
<td><?php echo $getCandidate['desired_location'];?></td>
<td><?php echo $getCandidate['notice_period'];?></td>
<td><?php echo $getCandidate['resume'];?></td>
</tr>
</tbody>

Categories

Resources