-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload.php
70 lines (68 loc) · 1.85 KB
/
upload.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
<?php
session_start();
include("class.upload.dao.php");
include_once("header.php");
$dao = new DAOupload();
?>
<center><b><u><font face ="Britannic Bold"><h1>Upload</h1></font></u></b></center><br>
<a href="form.upload.php" class="btn btn-info">Add upload</a><br>
<table class="table table-striped">
<tr class ="info">
<td>#</td>
<td>Title</td>
<td>Type</td>
<td>Date</td>
<td>Image</td>
<td><b>Edit</b></td>
<td><b>Delete</b></td>
</tr>
<?php
$rec_per_page = 10;
if(isset($_GET['page']))
$page = $_GET['page'];
else
$page = 1;
$limit1 = ($page-1)*$rec_per_page;
$limit2 = ($page)*$rec_per_page;
$total_recs = $dao->getCount();
$rec = $dao->getAllByUser($_SESSION["uid"],$limit1, $limit2);
$pages = ceil($total_recs/$rec_per_page);
if($page==1) $prev = $page;
else $prev=$page-1;
if($page==$pages) $next = $page;
else $next=$page+1;
$i = 0;
if($rec) foreach($rec as $row) {
$i++;
?>
<tbody>
<tr>
<td><? echo $i ?> </td>
<td><? echo $row->title ?> </td>
<td><? echo $row->type ?> </td>
<td><? echo $row->date ?> </td>
<td><? echo $row->img ?> </td>
<th><a href='form.upload.php?id=<? echo $row->upload_id ?>'><img src="img/edit.png" width = 20 height = 20 /></a></th>
<th><a href='delete.upload.php?id=<? echo $row->upload_id ?>'><img src="img/del.png" width = 20 height = 20 /></a></th>
</tr>
</tbody>
<?}
else echo "<tr><td colspan='8'><center><br><br><br><b>No Uploads are added yet.</b></center></td></tr>";
?>
</table>
<?
if($page != 1){
?> <a href="upload.php?page=<?=$prev?>" style="margin-right:20px">Prev</a>
<?}
for ($p =1; $p<=$pages ; $p++){
?> <a href="upload.php?page=<?=$p?>"><?=$p."/".$pages?></a>
<?
}
if($page != $pages){
?><a href="upload.php?page=<?=$next?>" style="margin-left:20px">Next</a>
<a href="upload.php?page=<?=$pages?>"style="margin-left:12px">Last</a><br />
<?}
?>
<?php
include("footer.php");
?>