-
Notifications
You must be signed in to change notification settings - Fork 0
/
compo-count-browse-all-data.php
85 lines (85 loc) · 2.76 KB
/
compo-count-browse-all-data.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
<?php
error_reporting(0);
require 'dbcon.php';
$term = str_replace("TO", "AND", $_POST['term'])??'';
$sort = $_POST['sort']??'';
$ad = $_POST['ad'] ?? '';
$activity = $_POST['activity']??'';
$target = $_POST['target']??'';
$organism = $_POST['organism']??'';
$exist = $_POST['exist']??'';
$length = $_POST['length']??'';
$dataset = explode("[", strtolower($_POST['ds']))[0]??'';
$lowerf = strtolower($term);
$upperf = strtoupper($term);
$selDs = '';
if ($dataset != 'master'){
$mdataset = ucfirst(str_replace("`","", str_replace(" dataset.tsv", "", $dataset)));
if ($mdataset == "Hemolytic" or $mdataset == "Metalloprotease" or $mdataset == "Protease" or $mdataset == "Ribosomal" or $mdataset == "Serine protease" or $mdataset == "Thiol protease" or $mdataset == "Toxin"){
$selDs = "AND `activity` LIKE '%".strrev($mdataset)."%'";
}
else{
$selDs = "AND `activity` LIKE '%".str_replace("`","", str_replace(" dataset.tsv", "", $dataset))."%'";
}
}
$finalQuery = array();
$sortFilter = '';
if (strlen($sort) != 0){
$sortFilter .= ' ORDER BY `'.$sort.'` '.$ad;
}
$preQuery = '';
$arr = explode(",", $activity);
if (strlen($arr[0]) > 0){
$preSQLarr = array();
foreach ($arr as $ele){
array_push($preSQLarr, "`activity` LIKE '%$ele%'");
}
$preQuery .= implode(" AND ", $preSQLarr);
array_push($finalQuery, $preQuery);
}
$preQuery = '';
$arr = explode(",", $target);
if (strlen($arr[0]) > 0){
$preSQLarr = array();
foreach ($arr as $ele){
array_push($preSQLarr, "`target organism` LIKE '%$ele%'");
}
$preQuery .= implode(" AND ", $preSQLarr);
array_push($finalQuery, $preQuery);
}
$preQuery = '';
$arr = explode(",", $organism);
if (strlen($arr[0]) > 0){
$preSQLarr = array();
foreach ($arr as $ele){
array_push($preSQLarr, "`Organism` LIKE '%$ele%'");
}
$preQuery .= implode(" AND ", $preSQLarr);
array_push($finalQuery, $preQuery);
}
$preQuery = '';
$arr = explode(",", $exist);
if (strlen($arr[0]) > 0){
$preSQLarr = array();
foreach ($arr as $ele){
array_push($preSQLarr, "`Protein existence` LIKE '%$ele%'");
}
$preQuery .= implode(" AND ", $preSQLarr);
array_push($finalQuery, $preQuery);
}
$preQuery = '';
$arr = explode(",", $length);
if (strlen($arr[0]) > 0){
$preQuery .= implode(" AND ", $arr);
array_push($finalQuery, $preQuery);
}
$filterQuery = implode(" AND ", $finalQuery);
if (strlen($filterQuery) > 0){
$filterQuery = " AND ".$filterQuery;
}
$sql = str_replace(" undefined", "", "SELECT COUNT(Serial_No) FROM `master2` WHERE ($term) $selDs $filterQuery $sortFilter");
$result = $con->query($sql);
$data = $result->fetch_all();
echo $data[0][0];
$con->close();
?>