forked from nisiya/MaristIDCP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram_search.php
154 lines (153 loc) · 5.27 KB
/
program_search.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
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
<!--Page for searching programs-->
<?php
$title = "IDCP - Program Search";
$page = 'program';
$page_name = 'search_prg';
require('includes/header.php');
//Making sure search from in the program is reset
unset($_SESSION['subSearchString']);
unset($_SESSION['suborder']);
if(!isset($_SESSION['searchString'])){
$_SESSION['searchString'] = "";
}
$searchString = $_SESSION['searchString'];
if(isset($_SESSION['reset'])){
unset($_SESSION['reset']);
$searchString = "";
$_SESSION['searchString'] = "";
}
# Connect to MySQL server and the database
require( 'includes/connect_db_c9.php' ) ;
# Includes these helper functions
require( 'includes/program_helpers.php' ) ;
if ($_SERVER[ 'REQUEST_METHOD' ] == 'POST') {
$_SESSION['searchString'] = mysqli_real_escape_string($dbc, trim($_POST['searchString']));
$page = 'program_search.php';
header("Location: $page");
}
?>
<style>
.button {
background-color: darkred;
bsuborder: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
<style>
input[type=text] {
width: 130px;
box-sizing: bsuborder-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 25%;
}
</style>
<!-- Bread Crumbs -->
<ol class = "breadcrumb">
<li><a href = "home.php">Home</a></li>
<li><a href = "program.php">Program</a></li>
<li class = "active">Program Search</li>
</ol>
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="dropdown">
<div class="page-header">
<h1>Search Programs<small> Click on a Program to view more</small><br></h1>
</div>
<font size="3">Search a Name: </font>
<form method="POST" action="program_search.php">
<input type="text" name="searchString" value ="<?php echo $searchString; ?>" placeholder="Search.."/>
<br>
<br>
<div class = "butspan" style = "width: 200px;">
<button type="submit" class="btn btn-primary btn-block" style="height: 50px;">Submit</button>
<button type="button" id='reset' class="btn btn-secondary btn-block">Reset</button>
</div>
</form>
<h3>Programs</h3>
<?php
show_brief_program_results($dbc, $searchString);
?>
<br>
<button class="btn btn-default btn-sm" onclick ="location.href='program.php';">Back to Program Home</button>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!--Footer-->
<?php require('includes/footer.php'); ?>
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!--Makes rows clickable-->
<script>
jQuery(document).ready(function($) {
$('.table > tbody > tr').click(function() {
var value = $(this).find('td:first').text();
jQuery.ajax({
url: 'backendprg.php',
type: 'POST',
data: {
'PRG_NAME': value
},
dataType : 'json',
success: function(data, textStatus, xhr) {
window.location.href = "program_profile.php";
console.log(data); // do with data e.g success message
},
error: function(xhr, textStatus, errorThrown) {
console.log(textStatus.reponseText);
window.location.href = "program_profile.php";
}
});
});
});
</script>
<!--Resets the search and sort-->
<script>
jQuery(document).ready(function($) {
$('#reset').click(function() {
jQuery.ajax({
url: 'reset.php',
type: 'POST',
data: {
'reset': "reset",
},
dataType : 'json',
success: function(data, textStatus, xhr) {
window.location.href = "program_search.php";
// alert('reset');
console.log(data); // do with data e.g success message
},
error: function(xhr, textStatus, errorThrown) {
// alert('reset');
console.log(textStatus.reponseText);
window.location.href = "program_search.php";
}
});
});
});
</script>
</body>
</html>