-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
95 lines (87 loc) · 3.19 KB
/
index.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
<!DOCTYPE html>
<?php include 'db.php';
$page = (isset($_GET['page']) ? $_GET['page'] : 1);
$perPage = (isset($_GET['per-page']) && ($_GET['per-page']) <= 50 ? $_GET['per-page'] : 5);
$start = ($page > 1) ? ($page * $perPage) - $perPage : 0;
$sql = "select * from tasks limit ".$start." , ".$perPage." ";
$total = $db->query("select * from tasks")->num_rows;
$pages = ceil($total / $perPage);
$rows = $db->query($sql);
?>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<title>Crud App</title>
</head>
<body>
<div class="container">
<center><h1>Todo list</h1></center>
<div class="row" style="margin-top: 70px;">
<div class="col-md-10 col-md-offset-1" >
<table class="table">
<button type="button" data-target="#myModal" data-toggle="modal" class="btn btn-success ">Add Task</button>
<button type="button" class="btn btn-default pull-right" onclick="print()">Print</button>
<hr><br>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Task</h4>
</div>
<div class="modal-body">
<form method="post" action="add.php">
<div class="form-group">
<label>Task Name</label>
<input type="text" required name="task" class="form-control">
</div>
<input type="submit" name="send" value="Add Task" class="btn btn-success">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="col-md-12 text-center">
<p>Search</p>
<form action="search.php" method="post" class="form-group">
<input type="text" placeholder="Search" name="search" class="form-control">
</form>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>ID.</th>
<th>Task</th>
</tr>
</thead>
<tbody>
<tr>
<?php while($row = $rows->fetch_assoc()): ?>
<th><?php echo $row['id'] ?></th>
<td class="col-md-10"><?php echo $row['name'] ?> </td>
<td><a href="update.php?id=<?php echo $row['id'];?>" class="btn btn-success">Edit</a> </td>
<td><a href="delete.php?id=<?php echo $row['id'];?>" class="btn btn-danger">Delete</a> </td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<center>
<ul class="pagination">
<?php for($i = 1 ; $i <= $pages; $i++): ?>
<li><a href="?page=<?php echo $i;?>&per-page=<?php echo $perPage;?>"><?php echo $i; ?></a></li>
<?php endfor; ?>
</ul>
</center>
<center>
</div>
</div>
</div>
</body>
</html>