-
Notifications
You must be signed in to change notification settings - Fork 0
/
order-info-views.php
149 lines (112 loc) · 3.37 KB
/
order-info-views.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
<?php
/*
VIEW.PHP
Displays all data from 'orders info' table
*/
// header
include('header.php');
// connect to the database
include('linkupdb.php');
//display clean utf8 data
function clean_ordersinfo($str)
{
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
return $str;
}
// number of results to show per page
$per_page = 100;
// figure out the total pages in the database
$result = mysql_query("SELECT o.orderNumber, o.productCode, o.quantityOrdered, o.priceEach, o.orderLineNumber, p.productCode, p.productName FROM orderdetails o, products p WHERE o.productCode = p.productCode");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);
// check if the 'page' variable is set in the URL (ex: view-paginated.php?page=1)
if (isset($_GET['page']) && is_numeric($_GET['page']))
{
$show_page = $_GET['page'];
// make sure the $show_page value is valid
if ($show_page > 0 && $show_page <= $total_pages)
{
$start = ($show_page -1) * $per_page;
$end = $start + $per_page;
}
else
{
// error - show first set of results
$start = 0;
$end = $per_page;
}
}
else
{
// if page isn't set, show first set of results
$start = 0;
$end = $per_page;
}
?>
<div id="orderdetails" class="fixed-wrapper"><h1 class="affix">Order Details</h1></div>
<div class="container">
<div class="content">
<div class="row">
<ul class="nav nav-pills">
<li class="badge pull-right"><a href="order-info-export.php">Export Records <i class="icon-cloud-download"></i></a></li>
</ul>
<!-- offices Section -->
<div class="content">
<div class="row-fluid">
<div class="col-md-12 col-sm-12 col-xs-12">
<?php
// pagination
echo " <ul class='pagination'> ";
for ($i = 1; $i <= $total_pages; $i++)
{
echo "<li><a href='order-info-views.php?page=$i'>$i</a></li>";
}
echo "</ul> ";
?>
<table class='table table-condensed' >
<thead>
<tr>
<th>orderNumber</th>
<th>productCode</th>
<th>quantityOrdered</th>
<th>priceEach</th>
<th>orderLineNumber</th>
</tr>
</thead>
<tbody>
<?php
// display data in table
// loop through results of database query, displaying them in the table
for ($i = $start; $i < $end; $i++)
{
// make sure that PHP doesn't try to show results that don't exist
if ($i == $total_results) { break; }
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . clean_ordersinfo(mysql_result($result, $i, 'orderNumber')) . '</td>';
echo '<td>' . clean_ordersinfo(mysql_result($result, $i, 'productName')) . '</td>';
echo '<td>' . clean_ordersinfo(mysql_result($result, $i, 'quantityOrdered')) . '</td>';
echo '<td>$' . clean_ordersinfo(mysql_result($result, $i, 'priceEach')) . '</td>';
echo '<td>' . clean_ordersinfo(mysql_result($result, $i, 'orderLineNumber')) . '</td>';
echo "</tr>";
}
echo "</tbody>";
// close table>
echo "</table>";
// pagination
echo " <ul class='pagination'> ";
for ($i = 1; $i <= $total_pages; $i++)
{
echo "<li><a href='order-info-views.php?page=$i'>$i</a></li>";
}
echo "</ul> ";
?>
</div>
</div>
</div>
<ul class="nav nav-pills">
<li class="badge pull-right"><a href="order-info-export.php">Export Records <i class="icon-cloud-download"></i></a></li>
</ul>
</div>
</div>
</div>