-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessages.php
More file actions
158 lines (123 loc) · 4.48 KB
/
messages.php
File metadata and controls
158 lines (123 loc) · 4.48 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
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
<?php
session_start(); // Start the session.
// If no session value is present, redirect the user:
if (!isset($_SESSION['employee_id'])) {
require_once ('includes/login_functions.inc.php');
$url = absolute_url('login.php');
header("Location: $url");
exit();
}
$page_title = 'View the Current Users';
include ('includes/header.html');
echo '<div id="content">
<div class="container">
<div class="inside">
<!-- box begin -->
<div class="box alt">
<div class="left-top-corner">
<div class="right-top-corner">
<div class="border-top"></div>
</div>
</div>
<div class="border-left">
<div class="border-right">
<div class="inner">
<div class="wrapper">
<h3>Messages</h3>';
require_once ('../mysqli_connect.php');
// Number of records to show per page:
$display = 5;
// Determine how many pages there are...
if (isset($_GET['p']) && is_numeric($_GET['p'])) { // Already been determined.
$pages = $_GET['p'];
} else { // Need to determine.
// Count the number of records:
$q = "SELECT COUNT(contact_id) FROM contactus";
$r = @mysqli_query ($dbc, $q);
$row = @mysqli_fetch_array ($r, MYSQLI_NUM);
$records = $row[0];
// Calculate the number of pages...
if ($records > $display) { // More than 1 page.
$pages = ceil ($records/$display);
} else {
$pages = 1;
}
} // End of p IF.
// Determine where in the database to start returning results...
if (isset($_GET['s']) && is_numeric($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
// Make the query:
//$q = "SELECT last_name, first_name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr, user_id FROM users ORDER BY registration_date ASC LIMIT $start, $display";
$q = "SELECT CONCAT (last_name, ', ', first_name) AS name, email, message, DATE_FORMAT(date_created,'%M %d, %Y') AS dr, contact_id FROM contactus ORDER BY date_Created ASC LIMIT $start, $display";
$r = @mysqli_query ($dbc, $q);
// Table header:
echo '<table align="center" cellspacing="2" cellpadding="10" width="100%">
<tr>
<td align="left"><b>Name</b></td>
<td align="left"><b>Email Address</b></td>
<td align="left"><b>Message</b></td>
<td align="left"><b>Date</b></td>
</tr>
';
echo '<p></p>';
// Fetch and print all the records....
$bg = '#eeeeee'; // Set the initial background color.
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$bg = ($bg=='#eeeeee' ? '#F0950D' : '#eeeeee'); // Switch the background color.
echo '<tr bgcolor="' . $bg . '">
<td align="left">' . $row['name'] .' </td>
<td align="left">' . $row['email'] . ' </td>
<td align="left"><a href="view_message.php?id=' . $row['contact_id'] . '">' . $row['message'] . '</a></td>
<td align="left"><small>' . $row['dr'] . '</small></td>
<td align="left"><a href="delete_message.php?id=' . $row['contact_id'] . '">Delete</a></td>';
//<td align="right"><a href="view_message.php?id=' . $row['contactus_id'] . '">view </a></td>'
} // End of WHILE loop.
echo '</table>';
mysqli_free_result ($r);
mysqli_close($dbc);
// Make the links to other pages, if necessary.
if ($pages > 1) {
// Add some spacing and start a paragraph:
echo '<br /><p>';
// Determine what page the script is on:
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous button:
if ($current_page != 1) {
echo '<a href="messages.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="messages.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
} else {
echo $i . ' ';
}
} // End of FOR loop.
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo '<a href="messages.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
}
echo '</p>'; // Close the paragraph.
} // End of links section.
echo ' <dl class="special fright">
</div>
</div>
</div>
</div>
<div class="left-bot-corner">
<div class="right-bot-corner">
<div class="border-bot"></div>
</div>
</div>
</div>
<!-- box end -->
<!--Recent articles list ends -->
</div>
</div>
</div>
';
include ('includes/footer.html');
?>