-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadmore.php
67 lines (64 loc) · 1.77 KB
/
loadmore.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
<?php include('config.php'); ?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body></body>
</html>
<?php
$resultsPerPage=4;
if(isset($_POST['page']))
{
$paged=$_POST['page'];
//$search = mysqli_real_escape_string($connect, $_POST["page"]);
if($_POST['search'] != "")
{
$search = $_POST["search"];
$page="SELECT * FROM users WHERE firstname LIKE '%$search%' OR lastname LIKE '%$search%' ORDER BY id ASC";
if($paged > 0)
{
$page_limit=$resultsPerPage*($paged-1);
$pagination_sql=" LIMIT $page_limit, $resultsPerPage";
}
else
{
$pagination_sql=" LIMIT 0 , $resultsPerPage";
}
}
else
{
$page="SELECT * FROM users ORDER BY id ASC";
if($paged > 0)
{
$page_limit=$resultsPerPage*($paged-1);
$pagination_sql=" LIMIT $page_limit, $resultsPerPage";
}
else
{
$pagination_sql=" LIMIT 0 , $resultsPerPage";
}
}
$result=mysqli_query($connect,$page.$pagination_sql);
while($row = mysqli_fetch_array($result))
{
echo '<div class="contain">';
echo $row['firstname']."<br>";
echo $row['lastname']."<br>";
echo $row['email']."<br>";
echo $row['gender']."<br>";
?><img src="<?php echo $row['picture'];?>" height='50' width='50'>
<?php echo "</div>";
}
$num_rows = mysqli_num_rows($result);
if($num_rows == $resultsPerPage){
?>
<li class="loadbutton"><button class="loadmore" data-page="<?php echo $paged+1 ;?>">Load More</button></li>
<?php
}
else
{
echo '<center><b>No More Data to Load</b></center>';
}
}
?>