I want show checkbox as a grid without scrolling the page. I am developing a attendance reporting page which shows student name and checkbox with values from database. I want to show its in a grid like this:
My code shows like this:
My code:
<table border="1" cellspacing="2" cellpadding="5" summary="">
<?php
while ($row = mysql_fetch_assoc($res)){?>
<th>
<input type="checkbox" class="input" id="input
<?php echo $row['st_id']; ?>"
name="student[]" value="<?php echo $row['st_id']; ?>"
checked="checked" >
<?php echo $row['st_name'] ; ?>
<label for="input<?php echo $row['st_id']; ?>">
</label>
</th>
This code take both name and checkbox id from the database..Anybody please help
You can use floating DIVs instead of table:
<style>
.inputDiv{
float: left;
padding: 5px;
margin: 5px;
border: 1px solid black;
}
</style>
<?php while ($row = mysql_fetch_assoc($res)) { ?>
<div class="inputDiv">
<input type="checkbox" class="input" id="input<?php echo $row['st_id']; ?>" name="student[]" value="<?php echo $row['st_id']; ?>" checked="checked" > <?php echo $row['st_name']; ?>
<label for="input<?php echo $row['st_id']; ?>"></label>
</div>
<?php } ?>
This will reorder automatically all DIVs depending of user's screen resolution.
You can use it like this:
<table border="1" cellspacing="2" cellpadding="5" summary="">
<?php
$counter = 1;
while ($row = mysql_fetch_assoc($res)){
if($number==1 ) {
echo '<tr>';
}
if($number %6 == 0) {
echo '</tr><tr>';
}
?>
<th> <input type="checkbox" class="input" id="input<?php echo $row['st_id']; ?>" name="student[]" value="<?php echo $row['st_id']; ?>" checked="checked" > <?php echo $row['st_name'] ; ?> <label for="input<?php echo $row['st_id']; ?>"></label></th>
<?php
$counter++;
if($number==0 || $number %6 == 0) {
echo '</tr>';
}
}
?>
</tr>
</table>
Related
I am currently building eCommerce site using CI HMVC method. I completed it for computer design and all back-end. It work perfectly. But my dessign is terrible for mobile so i decided to write jquery mobile code. I almost complete the code in jquery mobile but i got i problem which i cannot solve.
I have the form which is use to add the item into the cart. For this i have add to cart function which has view file add_to_Cart.php whis has actual form. After submitting form goes to store_basket/add_to_basket function. Here i writ code to sore the comming information to store_basket table. Then it redirect the page to another controller cart where i have view file of list of items which is in cart.
when i submit the form it store item in store_basketm table. Then it show the view of cart controller but the url is localhost/shop/store_basket/add_to_basket Which should be localhost/shop/cart. But despite of url localhost/shop/store_basket/add_to_basket it show the contents of localhost/shop/cart
<?php $form_location = base_url().'store_basket/add_to_basket'; ?>
<div id="cart" style="background-color: #ddd; border-spacing: 7px; padding: 7px; color: black;">
<form ajax-date="false" data-url="true" action="<?= $form_location ?>" method="POST">
<table class="table">
<tr>
<td>ID: </td>
<td><?php echo $item_id ?></td>
</tr>
<input type="hidden" name="item_id" value="<?php echo $item_id ?>">
<input type="hidden" name="item_title" value="<?php echo $item_title ?>">
<?php if($num_colour > 0): ?>
<tr>
<td style="padding-top: 20px;">Colour: </td>
<td style="margin-left: 50px;">
<?php
$status = '';
$additional_dd_code = 'name="select-choice-mini" id="select-choice-mini" data-mini="true" data-inline="true"';
echo form_dropdown('item_colour', $colour_options, $submitted_colour, $additional_dd_code);
?>
</td>
</tr>
<?php endif; ?>
<?php if($num_size > 0): ?>
<tr>
<td style="padding-top: 20px;">Size: </td>
<td style="margin-left: 50px;">
<?php
$status = '';
$additional_dd_code = 'name="select-choice-mini" id="select-choice-mini" data-mini="true" data-inline="true" style="background-color: white;"';
echo form_dropdown('item_size', $size_options, $submitted_size, $additional_dd_code);
?>
</td>
</tr>
<?php endif; ?>
<tr>
<td>Price: </td>
<td><?= $item_price ?></td>
</tr>
<input type="hidden" name="price" value="<?= $item_price ?>">
<tr>
<td style="padding-top: 20px;">Qty: </td>
<td>
<input type="number" name="item_qty" value="1" min="1" required>
</td>
</tr>
</table>
<!-- <a rel="external" href=""><input name="submit" value="Submit" class="btn"></a> -->
<button type="submit" name="submit" value="Submit" id="cart-btn" class="ui-shadow ui-btn ui-corner-all" style="margin-top: 20px; width: 75%; margin-left: 30px;"><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> Add To Basket</button>
<?php echo form_close() ?>
store_basket/add_to_basket
function add_to_basket() {
// var_dump($_POST); exit;
$this->load->module('site_settings');
$this->load->library('session');
$this->load->module('site_security');
$is_mobile = $this->site_settings->is_mobile_device();
$submit = $this->input->post('submit', TRUE);
if($submit == "Submit"){
//library for form validation
$this->load->library('form_validation');
//validation rules
$this->form_validation->set_rules('item_colour', 'Item Color', 'numeric');
$this->form_validation->set_rules('item_size', 'Item Size', 'numeric');
$this->form_validation->set_rules('item_qty', 'quantity', 'required|numeric');
$this->form_validation->set_rules('item_id', 'Item_id', 'required|numeric');
if($this->form_validation->run($this)) {
// echo "Success"; exit;
$data = $this->_fetch_the_data();
$this->_insert($data);
redirect('cart');
} else {
// echo "Fail"; exit;
$refer_url = $_SERVER['HTTP_REFERER'];
$error_msg = validation_errors("<p style='color: red;'>","</p>");
$this->session->set_flashdata('item', $error_msg);
redirect('cart');
}
}
}
cart/index.php
function index() {
// echo "here"; exit;
$this->load->module('site_settings');
$is_mobile = $this->site_settings->is_mobile_device();
$data['flash'] = $this->session->flashdata('item');
$data['view_files'] = "cart";
if($is_mobile==TRUE) {
$data['view_files'] .= "_jqm";
$template = 'public_jqm';
} else {
$template = 'public_boostrap';
}
$token = $this->uri->segment(3);
if($token!='') {
$session_id = $this->_check_and_get_session_id($token);
} else {
$session_id = $this->session->session_id;
}
$this->load->module('site_security');
$shopper_id = $this->site_security->_get_user_id();
if(!is_numeric($shopper_id)) {
$shopper_id = 0;
}
$table = 'store_basket';
$data['query'] = $this->_fetch_cart_contents($session_id, $shopper_id, $table);
//count the items in basket or cart
$data['num_rows'] = $data['query']->num_rows();
$data['showing_statement'] = $this->_get_showing_statement($data['num_rows']);
$this->load->module('templates');
$this->templates->$template($data);
}
I am having an issue with my shopping cart when I add three items only the last item enters into the database. I am not sure how to get all the items to insert into the database like 3 or 4. I have tried many different ways and still come up with nothing. I still have to also figure how to get subtotal and customer name to attach to the orders
Index.php
<?php
session_start();
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_GET["action"])) {
switch($_GET["action"]) {
case "add":
if(!empty($_POST["quantity"])) {
$productByCode = $db_handle->runQuery("SELECT * FROM tblproduct WHERE code='" . $_GET["code"] . "'");
$itemArray = array($productByCode[0]["code"]=>array('name'=>$productByCode[0]["name"], 'code'=>$productByCode[0]["code"], 'quantity'=>$_POST["quantity"], 'price'=>$productByCode[0]["price"]));
if(!empty($_SESSION["cart_item"])) {
if(in_array($productByCode[0]["code"],array_keys($_SESSION["cart_item"]))) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($productByCode[0]["code"] == $k) {
if(empty($_SESSION["cart_item"][$k]["quantity"])) {
$_SESSION["cart_item"][$k]["quantity"] = 0;
}
$_SESSION["cart_item"][$k]["quantity"] += $_POST["quantity"];
}
}
} else {
$_SESSION["cart_item"] = array_merge($_SESSION["cart_item"],$itemArray);
}
} else {
$_SESSION["cart_item"] = $itemArray;
}
}
break;
case "remove":
if(!empty($_SESSION["cart_item"])) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($_GET["code"] == $k)
unset($_SESSION["cart_item"][$k]);
if(empty($_SESSION["cart_item"]))
unset($_SESSION["cart_item"]);
}
}
break;
case "empty":
unset($_SESSION["cart_item"]);
break;
}
}
?>
<HTML>
<HEAD>
<TITLE>Simple PHP Shopping Cart</TITLE>
<link href="style.css" type="text/css" rel="stylesheet" />
</HEAD>
<BODY>
<div id="product-grid">
<div class="txt-heading">Products</div>
<?php
$product_array = $db_handle->runQuery("SELECT * FROM tblproduct ORDER BY id ASC");
if (!empty($product_array)) {
foreach($product_array as $key=>$value){
?>
<div class="product-item">
<form method="post" action="index.php?action=add&code=<?php echo $product_array[$key]["code"]; ?>">
<div class="product-image"><img src="<?php echo $product_array[$key]["image"]; ?>"></div>
<div><strong><?php echo $product_array[$key]["name"]; ?></strong></div>
<div class="product-price"><?php echo "$".$product_array[$key]["price"]; ?></div>
<div><input type="text" name="quantity" value="1" size="2" /><input type="submit" value="Add to cart" class="btnAddAction" /></div>
</form>
</div>
<?php
}
}
?>
</div>
<div id="shopping-cart">
<div class="txt-heading">Shopping Cart <a id="btnEmpty" href="index.php?action=empty">Empty Cart</a></div>
<?php
if(isset($_SESSION["cart_item"])){
$item_total = 0;
?>
<form method="post" action="process_insert.php">
<table cellpadding="10" cellspacing="1">
<tbody>
<tr>
<th style="text-align:left;"><strong>Name</strong></th>
<th style="text-align:left;"><strong>Code</strong></th>
<th style="text-align:right;"><strong>Quantity</strong></th>
<th style="text-align:right;"><strong>Price</strong></th>
<th style="text-align:center;"><strong>Action</strong></th>
</tr>
<?php
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;" ><input type="text" name="name" value="<?php echo $item["name"]; ?>"></td>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;"><input type="text" name="code" value="<?php echo $item["code"]; ?>"></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><input type="text" name="quantity" value="<?php echo $item["quantity"]; ?>"></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><input type="text" name="price" value="<?php echo $item["price"]; ?>"></td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">Remove Item</td>
</tr>
<?php
$item_total += ($item["price"]*$item["quantity"]);
}
?>
<tr>
<td colspan="5" align=right><strong>Total:</strong> <?php echo "$".$item_total; ?></td>
</tr>
</tbody>
</table>
<?php
}
?>
<input type="submit" name="submit" value="submit">
</form>
</div>
</BODY>
</HTML>
process_insert.php
<html>
<head>
<title></title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "";
$dbName = "blog_samples";
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$sql = "INSERT INTO order_table (name, code, quantity, price)
VALUES ('".$_POST["name"]."','".$_POST["code"]."'
,'".$_POST["quantity"]."','".$_POST["price"]."')";
$query = mysqli_query($conn,$sql);
if($query) {
echo "Record add successfully";
}
mysqli_close($conn);
?>
</body>
</html>
That's because your submit form doesnt support multiple fields.
You have to add a index to each inputs' name.
<?php
$i = 0;
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;" ><input type="text" name="name[<?php echo $i; ?>]" value="<?php echo $item["name"]; ?>"></td>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;"><input type="text" name="code[<?php echo $i; ?>]" value="<?php echo $item["code"]; ?>"></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><input type="text" name="quantity[<?php echo $i; ?>]" value="<?php echo $item["quantity"]; ?>"></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><input type="text" name="price[<?php echo $i; ?>]" value="<?php echo $item["price"]; ?>"></td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;">Remove Item</td>
</tr>
<?php
$item_total += ($item["price"]*$item["quantity"]);
$i++;
}
?>
process_insert.php
<html>
<head>
<title></title>
</head>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "";
$dbName = "blog_samples";
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$rows_count = count($_POST["name"]);
for($i=0;$i<$rows_count;$i++){
// PREVENTING SQL INJECTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$name = mysqli_real_escape_string($conn,$_POST["name"][$i]);
$code = mysqli_real_escape_string($conn,$_POST["code"][$i]);
$quantity = intval($_POST["quantity"][$i]);
$price = mysqli_real_escape_string($conn,$_POST["price"][$i]);
$sql = "INSERT INTO order_table (name, code, quantity, price)
VALUES ('$name','$code','$quantity','$price')";
$query = mysqli_query($conn,$sql);
}
if(mysqli_affected_rows($conn)>0) {
echo "Record add successfully";
}
mysqli_close($conn);
?>
</body>
</html>
I have created the following pages.
1. questions.php
2. functions.php
3. result.php
i have set the values of session variables on page function.php when the question form on questions.php form is submitted the functions.php code runs and the i have echo the values of session variables on result.php page. but i'm unable to get the session values result.the sessions values are resulting empty .anyone help please.
functions.php
if(isset($_POST['question_form']))
{
global $conn;
if (!isset($_SESSION['result'])) {
$result = 0;
$_SESSION['result'] = 0;
}
if (!isset($_SESSION['attempted'])) {
$attempted = 0;
$_SESSION['attempted'] = 0;
}
$resArray = array();
$resArray['message'] = '';
$resArray['status'] = '';
$no = $_POST['no'];
$postedAnswer = $_POST['answer_'.$no];
$question_id = $_POST['question_id'];
$subject_id = $_POST['subject_id'];
$sql = "SELECT True_answer FROM question WHERE QuestionId = '$question_id' AND SubjectId = '$subject_id'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$True_answer = $row['True_answer'];
if($postedAnswer === $True_answer)
{
$result = $_SESSION['result'];
$result++;
$_SESSION['result'] = $result;
}
$attempted = $_SESSION['attempted'];
$attempted++;
$_SESSION['attempted'] = $attempted;
$resArray['status'] = true;
//$resArray['q_id'] = $no;
$resArray['message'] = 'Submitted Successfully';
echo json_encode($resArray);
exit();
}
=====questions.php========
<form action="includes/functions.php" id="question_form_<?php echo $j; ?>" >
<div class='container' >
<div class='row'>
<div class='col-lg-12'>
<div class='thumbnail'>
<p id="question_description">Q.<?php echo $i; ?><br><?php echo $row['QuestionDescription']; ?></p>
<div class="questions_options">
<label><input type="radio" id="btn_radio" name="answer_<?php echo $j; ?>" value="<?php echo $row['Option1']; ?>"><?php echo $row['Option1']; ?></input></label><br>
<label><input type="radio" id="btn_radio" name="answer_<?php echo $j; ?>" value="<?php echo $row['Option2']; ?>"><?php echo $row['Option2']; ?></input></label><br>
<label><input type="radio" id="btn_radio" name="answer_<?php echo $j; ?>" value="<?php echo $row['Option3']; ?>"><?php echo $row['Option3']; ?></input></label><br>
<label><input type="radio" id="btn_radio" name="answer_<?php echo $j; ?>" value="<?php echo $row['Option4']; ?>"><?php echo $row['Option4']; ?></input></label><br><br>
<input type="hidden" name="question_id" value="<?php echo $row['QuestionId'] ?>">
<input type="hidden" name="subject_id" value="<?php echo $row['SubjectId'] ?>">
<input type="hidden" name="question_form" value="question_form">
<input type="hidden" name="no" value="<?php echo $j; ?>">
<button class="btn btn-primary btn-sm" id="btn_submit">Submit<i class="glyphicon glyphicon-arrow-right" >
</i></button>
</div>
</div>
</div>
</div>
</div>
</form>
============result.php===============
<table class="table table-striped table-hover" id="result_table" >
<thead>
<tr>
<th style="text-align: center;">Total Questions</th>
<th style="text-align: center;">Attempted Questions</th>
<th style="text-align: center;">Total Marks</th>
<th style="text-align: center;">Obtained Marks</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;"><?php echo $number_of_questions;?></td>
<td style="text-align: center;"><?php echo $_SESSION['attempted']; ?></td>
<td style="text-align: center;"><?php if(!isset($_SESSION['result']))
{
echo "empty";
}
else
{
echo $_SESSION['result'];
}
?></td>
<td style="text-align: center;"><?php echo $marks_obtained;?></td>
</tr>
</tbody>
</table>
Please start the session using session_start() function
I wanna check same exist database, but doesn't work the $check. What's wrong ı cannot find.
ı taking this error when post;
error 1-Members not added :(
Mysql error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''459' at line 1
error 2- 459 memb_id already in databese, try again!
This is my code:
<?php
$row_data = array();
foreach($_POST['checkbox'] as $row=>$Name) {
$name=mysql_real_escape_string($Name);
$memb_id=mysql_real_escape_string($_POST['memb_id'][$row]);
$memb_srnm=mysql_real_escape_string($_POST['memb_srnm'][$row]);
$kur_id=mysql_real_escape_string($_POST['kur_id'][$row]);
$row_data = array("'$memb_id'", "'$memb_srnm'", "'$kur_id'");
}
if (!empty($row_data)) {
$check = mysql_query("SELECT * FROM basvurular WHERE memb_id='$memb_id");
if (mysql_affected_rows() ){
echo '<h4 class="alert_error"><strong>'.ss($memb_id).'</strong> already in databese, try again! </h4>';
header('Location: index.php');
} else {
$query = 'INSERT INTO basvurular (memb_id, memb_srnm, basvur_kurid) VALUES (' .implode(',', $row_data) . ')';
}
if (mysql_query($query)){
echo '<h4 class="alert_success"> <label style="color: blue; font-size: 26px; font-weight: bold;"><img style="width: 4%" src="images/pers2.png" alt=""/>-'.mysql_affected_rows().'- </label> Succesfull :) </h4>';
header('Location: index.php');
}else{
echo '<h4 class="alert_error">Members not added :( <br> Mysql Error:'.mysql_error().'</h4>';
return false;}
}
?>
<article class="module width_3_quarter" style="padding-bottom: 10px; width: 95%">
<header>
<div style="float:right;font-size:14px;font-weight: bold; padding:10px"></div>
<h3 class="tabs_involved">POST SELECTED</h3>
</header>
<div class="tab_container">
<?php
$query = query("SELECT * FROM members INNER JOIN kurumlar ON kurumlar.kur_id = members.kur_id WHERE kurumlar.kur_id=' ".$_SESSION["kur_id"]." ' && ceza=0 ORDER BY memb_id DESC");
if (mysql_affected_rows()){
?>
<div id="tab1" class="tab_content">
<?php echo '<form action="" method="post" name="frm" onsubmit="return check">
<table class="tablesorter" cellspacing="0"> '; ?>
<thead>
<tr>
<th><a style="text-decoration: none;font-size:14px;font-weight: bold; color: blue" href="javascript:void(0);" id="link" onclick="slct()">All Select</a></th>
<th align= "left" >ID Number</th> <th></th>
<th align= "left" >USER NAME</th><label style="padding-right: 10px;padding-bottom: 10px;float:right " ><input style="color: red" type="submit" name="post" value="Selected Post"></label>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
while ($row = row($query)){
?>
<tr>
<td><input type="checkbox" name="checkbox[]" id="checkbox[]" ></td>
<td><?php echo ss($row["membName"]);?></td><td><input name="memb_id[]" type="hidden" value="<?php echo ss($row["memb_id"]);?>"></td>
<td><?php echo ss($row["memb_srnm"]);?></td><td><input name="memb_srnm[]" type="hidden" value="<?php echo ss($row["memb_srnm"]);?>"></td>
<td><input name="kur_id[]" type="hidden" value="<?php echo ss($_SESSION["kur_id"]);?>"></td>
</tr>
<?php }?>
</tbody>
<?php echo '</table></form>'; ?>
</div>
<?php }else{ ?>
<h4 class="alert_warning">Nobody Here :(( </h4>
<?php }?>
</div>
</article>
You're missing a quote on this line:
$check = mysql_query("SELECT * FROM basvurular WHERE memb_id='$memb_id'");
Also, to check whether a SELECT query returned any rows, you should use mysql_num_rows(), not mysql_affected_rows() -- the latter is only for queries that modify tables.
You should also check that the query is successful:
$check = mysql_query("SELECT * FROM basvurular WHERE memb_id='$memb_id")
or die(mysql_error());
On a page I have 8500 Employees shown in table data in the form of <tr> and <td>.
The Name of the Employees shown with a checkbox in front of each name of employee.
When I click on checkboxes the I insert the employees data (Employee Name and Employee Id) session.
Everything is working fine but the problem is when I click on check All checkbox then all the employees checkboxes are selected then there is a button named as "View Selected". On the click of this button I want to all the selected employees. When user click on this button a new child window will be opened with selected employee data in the form table row and data.
I am doing this but using session which I have created on the click of employees checkboxes.
Everything is working on Mozilla Firefox but when I check this of Google Chrome then it is not working and I am getting the browser message KillPages or Wait. The loader image of Chrome is shown but data is not loading.
My new child window page code is this where I am reading the session and running the for-each loop to print the data in the form of table data.
<?php require_once("../../includes/global.php");
$sessionName = rq('sessionName');
$employees = $session->read($sessionName);
?>
<script type="text/javascript" src="<?php echo SITEURL_PAGE; ?
>configuration/js/attendancePolicy.js"></script>
<div style="width: 100%;">
<?php if(strpos($sessionName, 'location') !== false) {?>
<h3 style="padding-left:10px;">View <?php echo LOCATION_DISPLAY_NAME?>s</h3>
<?php } else {?>
<h3 style="padding-left:10px;">View <?php echo
us(substr(str_replace('ot_','',$sessionName), 0, -3))?></h3>
<?php }?>
<?php
$totalEmployees = $session->check($sessionName) ? (int)count($session->read($sessionName)) : 0;
?>
<form id="updateEmployeesForm" name="updateEmployeesForm" method="post" action="saveAttendancePolicy.php">
<input type="hidden" name="hidAction" value="addNewPolicy_step3" />
<input type="hidden" name="sessionName" id="sessionName" value="<?php echo $sessionName?>" />
<?php
$styleTab = '';
$style='';
if($totalEmployees > 30){
$styleTab = 'border-bottom: none;';
$style = 'overflow:auto; height: 230px !important; border-bottom: 4px solid #2C90D3;';
}
//for over time policy only
$functionSuffix = '';
if($sessionName == 'ot_locations_cb' || $sessionName == 'ot_divisions_cb' || $sessionName == 'ot_departments_cb' || $sessionName == 'ot_employees_cb') {
$functionSuffix = 'overTimePolicy';
}
$where = rq('where');
$employeeLoadPage = ($sessionName == 'ot_employees_cb')?'otpolicy_ajax':'';
if(stripos($sessionName, 'employee') > -1) {
$js = "closeClildWindow('', 'employeeDiv', 'yes','".$employeeLoadPage."');";
} else if(stripos($sessionName, 'location') > -1) {
$js = "searchPolicySpecificNew('', 'locations', 'locationDiv', {'session':'yes'},'".$functionSuffix."'); updateChildPolicyNew('".$sessionName."', 'yes','".$functionSuffix."');";
} else if(stripos($sessionName, 'division') > -1) {
$js = "searchPolicySpecificNew('', 'divisions', 'divisionDiv', {'session':'yes'},'".$functionSuffix."'); updateChildDepartmentPolicyNew('".$sessionName."', 'locations_cb', 'yes','".$functionSuffix."');";
} else if(stripos($sessionName, 'department') > -1) {
$js = "searchPolicySpecificNew('', 'departments', 'departmentDiv', {'session':'yes'},'".$functionSuffix."'); updateChildjobTitlePolicy('".$sessionName."', 'divisions_cb', 'locations_cb', '','".$functionSuffix."');";
}
if($where == 'viewEmp') {
if($sessionName == 'ot_employees_cb') {
$js="getSelectedEmployeesNew('OT');";
} else {
$js="getSelectedEmployeesNew();";
}
}
?>
<div class="totalRecord" style="float:right; width:99%;text-align:right; margin-top: 5px;">
<label>Total Record(s) :<?php echo $totalEmployees ?></label>
</div>
<div style="margin: 0 2% 0 2%; width: 96%;" class="div_row">
<table cellpadding="0" border="0" cellspacing="0" width="100%" class="bdrtable" style="border-bottom: 0px;">
<thead>
<tr>
<th align="left" scope="col" colspan="5"> <input type="checkbox" name="viewCheckAllName" id="viewCheckAllName" <?php if($totalEmployees > 0) {?> checked="checked"<?php }?> class="class_parent_pop" onClick="sessionCheckBox('class_parent_pop', '<?php echo $sessionName?>_pop', 'parent', this);" />
Check All </th>
</tr>
</thead>
</table>
</div>
<div style="margin-bottom: 2%; margin-left: 2%; margin-right: 2%; width:96%;<?php echo $style;?>" class="div_row">
<table cellpadding="0" border="0" cellspacing="0" width="100%" class="bdrtable" style="<?php echo $styleTab?>">
<?php if($totalEmployees > 0) { ?>
<tr>
<?php $i=1;
foreach($employees as $key=>$employeeArr) {
?>
<td align="left" width="33%"><?php echo $i; ?> </td>
<?php
if($i%3 == 0 && $i != $totalEmployees) {
echo '</tr><tr>';
}
$i++;
}
if($totalEmployees%3 != 0) {
for ($x=($totalEmployees%3); $x < 3; $x++) {
echo '<td align="left" width="33%"> </td>';
}
}
?>
</tr>
<?php }else{ ?>
<tr>
<td colspan="3" align="center"><?php echo "No Data Found"; ?></td>
</tr>
<?php }?>
</table>
</div>
<div class="clear"></div>
<div class="div_row" style="text-align: right; width: 96%; margin:0 2%;">
<?php if($totalEmployees > 0) {?>
<input type="button" name="updateEmp" id="updateEmp" value="Update" class="submit" onClick="sessionCheckBoxPopupUpdate('<?php echo $sessionName?>_pop', '<?php echo $sessionName?>');<?php echo $js; ?>" />
<?php } ?>
<input type="button" name="cancel" id="cancel" value="Cancel" class="submit" onClick="javascript:window.close();" />
</div>
</form>
It may not be the foreach loop that is slow, 8500 is good number of data to load, you might want to page the results.
Why don't you try the same query using phpmyadmin and see the time taken.