Code: Select all
$targetpage = "view_all_chemicallab.php?lab_id=" . $_REQUEST['lab_id'];
Code: Select all
$targetpage = "view_all_chemicallab.php?lab_id=" . $_REQUEST['lab_id'];
Code: Select all
$paginate.= "<a href='$targetpage?page=$next'>next</a>";
Code: Select all
$paginate.= "<a href='{$targetpage}&page={$next}'>next</a>";
Code: Select all
if (isset($_POST['lab_id']) && is_numeric($_POST['lab_id']))
{
$lab_id = $_POST['lab_id'];
}
//else{$lab_id=1;}
$targetpage = "view_all_chemicallab.php?lab_id=" . $_REQUEST['lab_id'];
$limit = 2;
$query = "SELECT COUNT(*) as num FROM chemical
JOIN lab_inventory_chemical ON chemical.chemical_code = lab_inventory_chemical.chemical_code
WHERE lab_inventory_chemical.lab_id= '$lab_id' "; // this is line 71
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];
$stages = 3;
$page =isset($_GET['name'])?mysql_escape_string($_GET['page']): '';
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
/* $page = isset($_GET['name']) ? mysql_escape_string($_GET['page']): '';
$start = ($page - 1) * $limit; */
// Get page data
$query1 = "SELECT * FROM chemical
JOIN lab_inventory_chemical ON chemical.chemical_code = lab_inventory_chemical.chemical_code
WHERE lab_inventory_chemical.lab_id='$lab_id' LIMIT $start, $limit"; //this is line 86
$result = mysql_query($query1);
// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;
$paginate = '';
if($lastpage > 1)
{
$paginate .= "<div class='paginate'>";
// Previous
if ($page > 1){
$paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
}else{
$paginate.= "<span class='disabled'>previous</span>"; }
// Pages
if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few?
{
// Beginning only hide later pages
if($page < 1 + ($stages * 2))
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// Middle hide some front and some back
elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// End only hide early pages
else
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
}
// Next
if ($page < $counter - 1){
$paginate.= "<a href='{$targetpage}&page={$next}'>next</a>";
}else{
$paginate.= "<span class='disabled'>next</span>";
}
$paginate.= "</div>";
}
// get results from database
// $result = mysql_query("SELECT * FROM members")
// or die(mysql_error());
// display data in table
echo "<div>";
echo "<table id='table1'>";
echo "<tr> <th>Chemical Name</th> <th>Chemical Code</th> <th>Type</th> <th>Edit</th><th>Delete</th><th>Stock</th> </tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result ))
{
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>'. $row['name'] . '</td>';
echo '<td>' . $row['chemical_code'] . '</td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td><a href="editchemical.php?chemical_code=' . $row['chemical_code'] . '">Edit</a></td>';
echo "<td><a href=\"delete_chemical.php?chemical_code=" . $row['chemical_code'] ."\" * onclick=\"return confirm('Are you sure you want to delete?')\">Delete</a></td>";
echo '<td><a href="stock_chemical.php?chemical_code=' . $row['chemical_code'] . '">Stock</a></td>';
echo "</tr>";
}
echo "</table>";
echo $paginate;
echo "</div>";
echo '<pre>';print_r($_REQUEST);echo '</pre>';
Code: Select all
$page =isset($_GET['name'])?mysql_escape_string($_GET['page']): '';
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
Code: Select all
$page = isset($_GET['page'])?mysql_escape_string($_GET['page']): 1;
$start = ($page - 1) * $limit;
yeahI think isset($_GET['name']) part must be isset($_GET['page']). Is that correct?
Code: Select all
<?php
if (isset($_POST['lab_id']) && is_numeric($_POST['lab_id']))
{
$lab_id = $_POST['lab_id'];
}
//else{$lab_id=1;}
$targetpage = "view_all_chemicallab.php ? lab_id=".$_REQUEST['lab_id'];
$limit = 2;
$query = "SELECT COUNT(*) as num FROM chemical
JOIN lab_inventory_chemical ON chemical.chemical_code = lab_inventory_chemical.chemical_code
WHERE lab_inventory_chemical.lab_id= '$lab_id' "; // this is line 71
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];
$stages = 3;
/* $page =isset($_GET['name'])?mysql_escape_string($_GET['page']): '';
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
} */
$page_id = isset($_GET['page']) ? mysql_escape_string($_GET['page']): 1;
$start = ($page_id - 1) * $limit;
//echo $page_id;
// Get page data
$query1 = "SELECT * FROM chemical
JOIN lab_inventory_chemical ON chemical.chemical_code = lab_inventory_chemical.chemical_code
WHERE lab_inventory_chemical.lab_id='$lab_id' LIMIT $start, $limit"; //this is line 86
$result = mysql_query($query1);
// Initial page num setup
if ($page_id == 0){$page_id = 1;}
$prev = $page_id - 1;
$next = $page_id + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;
$paginate = '';
if($lastpage > 1)
{
$paginate .= "<div class='paginate'>";
// Previous
if ($page_id > 1){
$paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
}else{
$paginate.= "<span class='disabled'>previous</span>"; }
// Pages
if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page_id){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few?
{
// Beginning only hide later pages
if($page_id < 1 + ($stages * 2))
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// Middle hide some front and some back
elseif($lastpage - ($stages * 2) > $page_id && $page_id > ($stages * 2))
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $page_id - $stages; $counter <= $page_id + $stages; $counter++)
{
if ($counter == $page_id){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// End only hide early pages
else
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page_id){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
}
// Next
if ($page_id < $counter - 1){
$paginate.= "<a href='$targetpage?page=$next'>next</a>";
}else{
$paginate.= "<span class='disabled'>next</span>";
}
$paginate.= "</div>";
}
// get results from database
// $result = mysql_query("SELECT * FROM members")
// or die(mysql_error());
// display data in table
echo "<div>";
echo "<table id='table1'>";
echo "<tr> <th>Chemical Name</th> <th>Chemical Code</th> <th>Type</th> <th>Edit</th><th>Delete</th><th>Stock</th> </tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result ))
{
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>'. $row['name'] . '</td>';
echo '<td>' . $row['chemical_code'] . '</td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td><a href="editchemical.php?chemical_code=' . $row['chemical_code'] . '">Edit</a></td>';
echo "<td><a href=\"delete_chemical.php?chemical_code=" . $row['chemical_code'] ."\" * onclick=\"return confirm('Are you sure you want to delete?')\">Delete</a></td>";
echo '<td><a href="stock_chemical.php?chemical_code=' . $row['chemical_code'] . '">Stock</a></td>';
echo "</tr>";
}
echo "</table>";
echo $paginate;
echo "</div>";
echo '<pre>';print_r($_REQUEST);echo '</pre>';
Code: Select all
$paginate.= "<a href='$targetpage?page=$next'>next</a>";
Code: Select all
$paginate.= "<a href='{$targetpage}&page={$next}'>next</a>";
Code: Select all
$paginate .= '<a href="' . $targetpage . '&page=' . $next . '">next</a>';
Code: Select all
<?php
require_once('auth.php');
include("config.php");
if (isset($_SESSION['SESS_ID']) && is_numeric($_SESSION['SESS_ID']))
{
$emp_id = $_SESSION['SESS_ID'];
}
$result2 = mysql_query("Select *
from members
JOIN lab_employee on members.emp_id = lab_employee.emp_id
JOIN lab on lab_employee.lab_id = lab.lab_id
where members.emp_id=$emp_id")
or die(mysql_error());
?>
<form name="labwise" method="post" action="view_all_chemicallab.php" onsubmit="return validateForm()" >
<div>Select laboratory :
<?php
$dropdown = "<select name='lab_id' id='lab_id' >";
$dropdown .= "<option value=''>Select lab to assign </option>";
while($row2 = mysql_fetch_assoc($result2))
{
$dropdown .= "\r\n<option value='{$row2['lab_id']}'>{$row2['l_name']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>
<input type="submit" value="view chemicals" />
</div></form>
Code: Select all
CREATE TABLE IF NOT EXISTS `chemical` (
`chemical_code` varchar(10) NOT NULL,
`name` varchar(20) NOT NULL,
`type` varchar(10) NOT NULL,
`notes` varchar(200) DEFAULT NULL,
PRIMARY KEY (`chemical_code`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `chemical`
--
INSERT INTO `chemical` (`chemical_code`, `name`, `type`, `notes`) VALUES
('B0008', 'Br2', 'Gas', 'frfr'),
('H0001', 'HCL', 'Solid', '50%'),
('H0002', 'HF', 'Gas', ''),
('H0004', 'H2', 'Gas', ''),
('H003', 'H2SO4', 'liquid', '56'),
('HA050', 'HAC 50%', 'Liquid', 'NEW'),
('S0005', 'SO2', 'Gas', ''),
('S5060', 'SO', 'Solid', '');
CREATE TABLE IF NOT EXISTS `lab` (
`lab_id` int(10) NOT NULL AUTO_INCREMENT,
`l_name` varchar(50) NOT NULL,
`incharge` varchar(50) NOT NULL,
`notes` varchar(250) DEFAULT NULL,
PRIMARY KEY (`lab_id`),
UNIQUE KEY `name` (`l_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
--
-- Dumping data for table `lab`
--
INSERT INTO `lab` (`lab_id`, `l_name`, `incharge`, `notes`) VALUES
(1, 'Organic Lab', 'Samanthi', 'ewewdsa'),
(2, 'Physical Lab', 'Kamal', ''),
(3, 'Inorganic Lab ', 'Sahan', ''),
(4, 'Advance Lab', 'Kamal', ''),
(6, 'BioChemistry Lab', 'dili', ''),
(7, 'Card Lab', 'sahan', 'abd'),
(8, 'Elementry Lab', 'dili', ''),
(9, 'New Biochemistry Lab', 'Sachin', ''),
(10, 'Phamacy Lab', 'Sachini', '');
CREATE TABLE IF NOT EXISTS `lab_employee` (
`lab_id` int(10) NOT NULL,
`emp_id` int(10) NOT NULL,
`labemp_id` int(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`labemp_id`),
KEY `emp_id` (`emp_id`),
KEY `lab_id` (`lab_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;
INSERT INTO `lab_employee` (`lab_id`, `emp_id`, `labemp_id`) VALUES
(1, 175, 12),
(2, 175, 13),
(3, 175, 14),
(8, 175, 15),
(9, 175, 16),
(1, 114, 17),
(2, 114, 18),
(3, 114, 19);
CREATE TABLE IF NOT EXISTS `lab_inventory_chemical` (
`lab_id` int(10) NOT NULL,
`chemical_code` varchar(10) NOT NULL,
`quantity` decimal(10,2) NOT NULL,
`units` varchar(10) NOT NULL,
`reorder_level` decimal(10,2) NOT NULL,
`lic_id` int(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`lic_id`),
KEY `lab_id` (`lab_id`),
KEY `chemical_code` (`chemical_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;
INSERT INTO `lab_inventory_chemical` (`lab_id`, `chemical_code`, `quantity`, `units`, `reorder_level`, `lic_id`) VALUES
(1, 'H0001', '40000.00', 'L', '808.00', 4),
(1, 'H003', '202.00', 'L', '56.00', 7),
(1, 'H0004', '85.00', 'L', '9.00', 9),
(1, 'B0008', '5000.00', 'l', '100.00', 13),
(3, 'B0008', '500.00', 'L', '50.00', 19),
(2, 'H0004', '800.00', 'L', '50.00', 20),
(2, 'HA050', '800.00', 'L', '504.00', 21),
(3, 'H003', '806.00', 'L', '56.00', 22),
(3, 'HA050', '806.00', 'L', '56.00', 23),
(3, 'S0005', '806.00', 'L', '56.00', 24);
CREATE TABLE IF NOT EXISTS `members` (
`emp_id` int(5) NOT NULL,
`login` varchar(10) NOT NULL,
`password` varchar(100) NOT NULL,
`type` varchar(20) NOT NULL,
`email` varchar(100) NOT NULL,
PRIMARY KEY (`emp_id`),
UNIQUE KEY `login` (`login`),
KEY `login_2` (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `members` (`emp_id`, `login`, `password`, `type`, `email`) VALUES
(114, 'Chanake', '5d58c4a8bb8332d69cb9b152e9524ff4', 'labassistant', '[email protected]'),
(154, 'bobi', '51e4a5611b485ee7d5dcd421c092563b', 'admin', '[email protected]'),
(175, 'suba', '3538fc1dd47d3e92ac62dabd91d45aef', 'admin', '[email protected]');