-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable_data.php
More file actions
76 lines (62 loc) · 2.63 KB
/
Copy pathtable_data.php
File metadata and controls
76 lines (62 loc) · 2.63 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
<?php
$sql = "SELECT * FROM staff";
$countries = array();
$colNotCountries = array();
$colNames = array();
$employeesNames = array();
$employeesRawNames = array();
$fullArray = array();
try
{
$db_connection = connect_to_db();
// echo $sql." ";
set_utf8_polish_ci($db_connection);
$result = send_query($db_connection, $sql);
$rows_nr = mysqli_num_rows($result);
for($i=0; $i<$rows_nr; ++$i)
{
$row = mysqli_fetch_assoc($result);
if($i==0){
foreach($row as $colname => $val){
if($colname != 'id' && $colname != 'name' && $colname != 'surname'
&& $colname != 'image' && $colname != 'href' && $colname != 'country'){
array_push($colNames, $colname);
array_push($colNotCountries, $colname);
}
}}
for ($j=0; $j<count($colNames); ++$j){
if( strcmp($colNames[$j], $row['country']) == 0 ){
break;
}
if( $j+1 == count($colNames) ){
array_push($colNames, $row['country']);
array_push($countries, $row['country']);
}
}
}
mysqli_data_seek($result, 0);
for($i=0; $i<$rows_nr; $i++)
{
$row = mysqli_fetch_assoc($result);
$rawData = $row['name']." ".$row['surname'];
$data = slugify($rawData);
$employeesNames[$i] = $data;
$employeesRawNames[$i] = $rawData;
echo '<li style="user-select: none;" onclick="leftPanelButtonClick(this)" id="'.$data.'" >'.$rawData.'</li>
';
for($j=0; $j<count($colNames); $j++){
if( isset($row[$colNames[$j]]) ){
$fullArray[$data][$colNames[$j]] = $row[$colNames[$j]];
}else{
$fullArray[$data][$colNames[$j]] = 0;
if( strcmp($row['country'], $colNames[$j]) == 0 ){
$fullArray[$data][$colNames[$j]] = 1;
}
}
}
}
$_SESSION['colNames'] = $colNames;
$_SESSION['colNotCountries'] = $colNotCountries;
}
catch(Exception $e) { echo $e; }
?>