-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproblem.php
More file actions
66 lines (60 loc) · 1.55 KB
/
problem.php
File metadata and controls
66 lines (60 loc) · 1.55 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
<?php
session_start() ;
$db_host = 'localhost' ;
$db_database = 'pd course' ;
$db_username = 'root' ;
$connection = mysql_connect($db_host, $db_username, 'pdogsserver');
if (!$connection)
die ("connection failed".mysql_error()) ;
mysql_query("SET NAMES 'utf8'");
$selection = mysql_select_db($db_database) ;
if (!$selection)
die ("selection failed".mysql_error()) ;
if (!isset($_SESSION['account'])){
header ("Location:index.php") ;
} else {
$query_pd = "SELECT p_id FROM pd_hw";
$pd_id = mysql_query($query_pd);
$query_lab = "SELECT lab_id FROM lab_hw";
$lab_id = mysql_query($query_lab);
?>
<div class="hero-unit upload_section">
<p>PD Problems</p>
<table class="table table-hover">
<?php
$count = 0;
while ($fetch_pd = mysql_fetch_row($pd_id)){
if ($count%3 == 0) echo '<tr>';?>
<td><a href='./problem/<?php echo $fetch_pd[0]; ?>.pdf' target='_blank'><?php echo $fetch_pd[0]; ?></a></td>
<?php
if ($count%3 == 2){
echo '</tr>';
$count = 0;
} else {
$count++;
}
}
?>
</table>
<p>LAB Problems</p>
<table class="table table-hover">
<?php
$count = 0;
while ($fetch_lab = mysql_fetch_row($lab_id)){
if ($count%3 == 0) echo '<tr>';?>
<td><a href='./problem/<?php echo $fetch_lab[0]; ?>.pdf' target='_blank'><?php echo $fetch_lab[0]; ?></a></td>
<?php
if ($count%3 == 2){
echo '</tr>';
$count = 0;
} else {
$count++;
}
}
if ($count < 2) echo '</tr>';
?>
</table>
</div>
<?php
}
?>