-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_hardware.php
More file actions
75 lines (70 loc) · 3.01 KB
/
fetch_hardware.php
File metadata and controls
75 lines (70 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
session_start();
require_once "pdo.php";
if(isset($_POST['cancel']))
{
header("Location: index.php");
return;
}
if( !isset($_SESSION['id'])&&$_SESSION['role']!=0 )
{
die('ACCESS DENIED');
}
if(isset($_POST['chillana']))
{
$stmtcnt = $pdo->query("SELECT COUNT(*) FROM hardware");
$row = $stmtcnt->fetch(PDO::FETCH_ASSOC);
if($row['COUNT(*)']!=='0')
{
$i=1;
$stmtread=$pdo->prepare("SELECT name_id from name where name =:name");
$stmtread->execute(array(":name"=>$_POST['chillana']));
$nameid=$stmtread->fetch(PDO::FETCH_ASSOC);
$stmtread = $pdo->prepare("SELECT * FROM hardware where name= :name AND state=:state ORDER BY name");
$stmtread->execute(array(":name"=>$nameid['name_id'],":state"=>$_POST['state']));
echo ("<table class=\"table table-striped col-xs-12\">
<tr> <th>S.no.</th><th>Hardware ID</th><th>Name</th><th>description</th><th>Company</th><th>GRN</th><th>Supplier</th><th>State</th></tr>");
while ( $row = $stmtread->fetch(PDO::FETCH_ASSOC) )
{
$stmtn = $pdo->prepare("SELECT name FROM company where company_id = :cname ");
$stmtn->execute(array(':cname' => $row['company']));
$cname = $stmtn->fetch(PDO::FETCH_ASSOC);
$supplier = $pdo->prepare("SELECT supname FROM supplier where sup_id = :sid");
$supplier->execute(array(':sid' => $row['supplier']));
$supplierid = $supplier->fetch(PDO::FETCH_ASSOC);
echo ("<tr>");
echo ("<td>");
echo($i);
echo("</td>");
echo "<td>";
echo $row['hardware_id'];
echo "</td>";
echo ("<td>");
echo(htmlentities($_POST['chillana']));
echo ("</td>");
echo ("<td>");
echo(htmlentities($row['description']));
echo ("</td>");
echo ("<td>");
echo(htmlentities($cname['name']));
echo ("</td>");
echo ("<td>");
echo(htmlentities($row['grn']));
echo ("</td>");
echo ("<td>");
echo(htmlentities($supplierid['supname']));
echo ("</td>");
echo ("<td>");
if($_POST['state']==0)
echo "Unpositoned";
else if($_POST['state']==1)
echo "Positioned";
else if($_POST['state']==2)
echo "Issued";
echo ("</td>") ;
$i++;
}
echo('</table>');
}
}
?>