-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewTable.php
84 lines (78 loc) · 2.86 KB
/
viewTable.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
<?php //Table details
session_start();
require('dbparam.php');
$table=$_GET['table']; //Which table (passed from search)
function detailTable ($nomeTabella, $stringaRicerca) { //filtering tables (show rows only for logic/parametric tables - naming convention needed e.g. all tables starts with LTAB..,PTAB..)
return substr($nomeTabella, 0 ,strlen($stringaRicerca)) == $stringaRicerca;
}
?>
<html>
<head>
<title>Table detail - <?php echo $table; ?></title>
<link rel="stylesheet" href="css/style.css" type="text/css"></style>
<script src="js/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<h1><?php echo $table; ?></h1>
<?php
$stid = oci_parse($db, "SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH FROM USER_TAB_COLS WHERE table_name='$table'");
oci_execute($stid);
echo "<table class=\"blueTable\">\n";
echo "<thead><tr align=\"center\"><th>NOME CAMPO</th><th>TIPO</th><th>LUNGHEZZA</th><th>NOTE</th></tr></thead>\n";
$fields=array();
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
$first=0;
echo "<tr class=\"result\">\n";
foreach ($row as $item) {
if($first==0) array_push($fields,($item !== null ? htmlentities($item, ENT_QUOTES) : " "));
echo "<td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
$first++;
}
echo "<td><input type\"text\" size=\"100\"> </td>\n";
echo "</tr>\n";
}
oci_free_statement($stid);
?>
<script type="text/javascript">
$(document).ready(function() {
$(".blueTable tr").click(function() {
var selected = $(this).hasClass("highlight");
//$(".blueTable tr").removeClass("highlight");
if(!selected){
$(this).removeClass("result");
$(this).addClass("highlight");
}
else {
$(this).addClass("result");
$(this).removeClass("highlight");
}
});
});
</script>
</table>
<?php
$detailTab=false;
for ($i=0;$i<sizeof($_SESSION['ltTables']);$i++) //from config file (all tables that start with a defined naming convention)
$detailTab = $detailTab || detailTable($table,$_SESSION['ltTables'][$i]); //parametric table?
if(($table{0}=="L")||($table{0}=="T")||($detailTab)) { //if yes, show relative rows
echo "<h2>Dettagli tabella</h2>";
$stid = oci_parse($db, "SELECT * FROM $table");
oci_execute($stid);
echo "<table class=\"blueTable\">\n";
echo "<thead><tr align=\"center\">";
for ($i=0;$i<sizeof($fields);$i++)
echo "<th>".$fields[$i]."</th>";
echo "\n";
echo "</tr></thead>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr class=\"result\">\n";
foreach ($row as $item) {
echo "<td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
oci_free_statement($stid);
}
?>
</body>
</html>