This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplayLocations.php
91 lines (85 loc) · 3.62 KB
/
DisplayLocations.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
<?php
include('session.php');
include('SQLFunctions.php');
$table = 'location';
$title = "SVBX - Display Locations";
include('filestart.php');
$link = f_sqlConnect();
//echo '<br>Source table: ' .$table;
// if(!f_tableExists($link, $table, DB_NAME)) {
// die('<br>Destination table does not exist: '.$table);
// }
$sql = "SELECT LocationID, LocationName, lastUpdated, updatedBy FROM $table ORDER BY LocationName";
$sql1 = "SELECT COUNT(*) FROM $table";
if($result = mysqli_query($link,$sql1)) {
echo"
<header class='container page-header'>
<h1 class='page-title'>Locations</h1><br />
<table class='sumtable'>
<tr class='sumtr'>
<td class='sumtd'>Locations in Database: </td>";
while ($row = mysqli_fetch_array($result)) {
echo "<td class='sumtd'>{$row[0]}</td>";
}
echo "</table><br></header>";
}
if($result = mysqli_query($link,$sql)) {
echo"
<div class='container main-content'>
<table class='table'>
<tr class='usertr'>
<th class='userth'>Location ID</th>
<th class='userth'>Location</th>";
if(!isset($_SESSION['userID']))
{
echo "</tr>";
} else {
echo "
<th class='userth'>Last Updated</th>
<th class='userth'>Updated By</th>";
if($role >= 30) {
echo "
<th class='userth'>Edit</th>";
}
if($role >= 40) {
echo "
<th class='userth'>Delete</th>";
}
echo "
</tr>";
}
while ($row = mysqli_fetch_array($result)) {
echo" <tr class='usertr'>
<td style='text-align:center' class='usertd'>{$row[0]}</td>
<td class='usertd'>{$row[1]}</td>";
if(!isset($_SESSION['userID']))
{
echo "</tr>";
} else {
echo "
<td class='usertd'>{$row[2]}</td>
<td class='usertd'>{$row[3]}</td>";
if($role >= 30) {
echo "
<td class='usertd'><form action='UpdateLocation.php' method='POST' onsubmit=''/>
<input type='hidden' name='q' value='".$row[0]."'/><input type='submit' value='Update'></form></td>";
}
if($role >= 40) {
echo "
<td class='usertd'><form action='DeleteLocation.php' method='POST' onsubmit='' onsubmit='' onclick='return confirm(`do you want to delete {$row[1]} location`)'/>
<button type='Submit' name='q' value='".$row[0]."'><i class='typcn typcn-times'></i></button></form></td>";
}
echo "</tr>";
}
}
echo "</table></div>";
}
mysqli_free_result($result);
if(mysqli_error($link)) {
echo '<br>Error: ' .mysqli_error($link);
} else //echo '<br>Success';
mysqli_close($link);
?>
<?php include 'fileend.php';?>
</Body>
</HTML>