-
Notifications
You must be signed in to change notification settings - Fork 0
/
material_type.php
194 lines (166 loc) · 5.82 KB
/
material_type.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
session_start();
if (!isset($_SESSION["username"])) {
header("location:admin_login.php");
exit;
}
include "include/connect.php";
include "include/gensettings.php";
//############PAGINATION ################
/**Set current,
*prev and next page
*/
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
$prev = ($page - 1);
$next = ($page + 1);
/**Max results
*per page
*/
$max_results = $rec_per_page;
/* Calculate the offset */
$from = (($page * $max_results) - $max_results);
/**Query the db for total
*results. You need to edit
*the sql to fit your needs
*/
$sql = "SELECT * from material_type order by mat_type";
$result = mysql_query($sql);
$total_results = mysql_num_rows($result);
$number = $total_results;
$total_pages = ceil($total_results / $max_results);
//echo $total_results;
$pagination = '';
/* Create a PREV link if there is one */
if ($page > 1) {
//pass the values of the $txt variables
$pagination .= '<a href="material_type.php?page=' . $prev . '"
title="Previous"> <Previous</a> ';
} else {
$pagination .= '<strong> <Previous</strong> ';
}
// Loop through the total pages
for ($i = 1; $i <= $total_pages; $i++) {
if (($page) == $i) {
$pagination .= $i;
} else {
$pagination .= ' <a href="material_type.php?page=' . $i . '" title="page ' . $i . '">' . $i . '</a> ';
}
}
/* Print NEXT link if there is one */
if ($page < $total_pages) {
$pagination .= '<a href="material_type.php?page=' . $next . '"
title="Next">Next ></a>';
} else {
$pagination .= ' <strong>Next ></strong>';
}
$sql .= " LIMIT $from, $max_results";
$result = mysql_query($sql, $connect) or die("cant execute query!.....");
$mga_resulta = mysql_num_rows($result);
//echo $mga_resulta;
//echo $sql;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/JavaScript">
<!--
function MM_openBrWindow1(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title><?php echo $system_title . "--" . $footer; ?></title>
<link rel="stylesheet" href="css/<?php echo $css; ?>" type="text/css" />
</head>
<body >
<div class="header">
<div class="logo"><?php echo " " . $header_title; ?> </div>
<div id="Layer1"><img src="images/<?php echo $logo; ?>" width="117" height="110" />
<div id="Layer2"></div>
</div></div>
<div class="navbg">
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="home.php" id="current" title="Home">Home</a></li>
<li><a href="admin.php" title="Search">Search</a></li>
<li><a href="admin_add_new.php" title="Add book">Add book</a></li>
<li><a href="barrower.php" title="Borrower">Borrower</a></li>
<li><a href="inventory.php" title="Inventory">Inventory</a></li>
<li><a href="settings.php" title="Settings">Settings</a></li>
<li><a href="help1.php" title="Help">Help</a></li>
<li><a href="logout.php" title="Logout">Logout</a></li>
</ul>
</div>
</div>
<!-- Start of Page Menu -->
<!-- End of Page Menu -->
<!-- Start of Left Sidebar -->
<!-- End of Left Sidebar -->
<!-- Start of Main Content Area -->
<div id="main_content202">
<!-- Start of New Item Description -->
<div id="new_item202">
<fieldset>
<legend class="style1">Material Type </legend>
<form action="material_type.php" method="post" id="myform" name="myform">
<table width="83%" border="0" cellpadding="5" cellspacing="5">
<tr>
<td colspan="4"><?php
if (strlen($pagination) < 100) {
$pagination = "";
}
echo $pagination;?></td>
</tr>
<?php if ($total_resuts != 0) {echo '<strong><img src="images/arrowr.gif" width="15" height="9" /> We have </strong>
<strong>' . $total_results . ' Type(s) of Material in this system</strong><br><br><hr/>';}?>
<tr>
<td height="30" class="style2" colspan="4" align="left"><a href="add_mat_type.php">Add New Material Type </a></td>
</tr>
<tr align="center">
<td colspan="2"><strong>Function</strong></td>
<td width="44%"><strong>Material Type </strong></td>
<td width="35%"><strong>Description</strong></td>
</tr>
<?php
$x = 2;
$y = 1;
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$mat_type = $row['mat_type'];
$desc = $row['description'];
if ($x > $y) {
$y += 2;
$bg = "#ECE9D8";
} else {
$x += 2;
$bg = "#Ffffff";
}
?>
<tr>
<td width="9%" bgcolor="<?php echo $bg; ?>" align="right"><div align="center"><strong> <a href="edit_mat_type.php?id=<?php echo $id; ?>">Edit</a></strong></div></td>
<td width="12%" bgcolor="<?php echo $bg; ?>"><div align="center"><strong><a href="del_mat_type.php?id=<?php echo $id; ?>&mat_type=<?php echo $mat_type; ?>">Delete</a></strong></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center"><?php echo $mat_type; ?></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center"><?php echo $desc; ?></div></td>
</tr>
<?php }?>
<tr>
<td colspan="4"><?php
if (strlen($pagination) < 100) {
$pagination = "";
}
echo $pagination;?></td>
</tr>
<?php if ($total_resuts == 0) {echo '<strong><img src="images/arrowr.gif" width="15" height="9" /> We have </strong>
<strong>' . $total_results . ' Type(s) of Material in this system</strong><br><br><hr/>';}?>
</table>
</form>
</fieldset></div></div>
<!-- End of New Item Description -->
<!-- Start of Sub Item Descriptions -->
</body>
</html>