Jump to content
Sign in to follow this  
etsted

concatenation

Recommended Posts

the thing whit this pagination script is that it works, but then thing is that it concatenates all of my "titles" into on link. But if i take away the concatenation then the pagination will only display one item from my database.

 

include "connect.php";
$count_query = mysqli_query($con, "SELECT NULL FROM videos");
$count = mysqli_num_rows($count_query);
if(isset($_GET['search'])) {
$page = preg_replace("#[^0-9]#","",$_GET['search']);
} else {
$page = 1;
}
$perPage = 2;
$lastPage = ceil($count/$perPage);
if($page < 1) {
$page = 1;
} else {
if($page > $lastPage) {
$page = $lastPage;
}
}
$limit = "LIMIT " . ($page - 1) * $perPage . ", $perPage";
$query = mysqli_query($con, "SELECT * FROM videos ORDER BY id DESC $limit");
if($lastPage != 1) {
if($page != 1) {
$prev = $page - 1;
$pagination .= '<a href="pagination.php?search='.$prev.'">Previous</a> ';
}
if($page != $lastPage) {
$next = $page + 1;
$pagination .= '<a href="pagination.php?search='.$next.'">Next</a>';
}
}
while($row = mysqli_fetch_array($query)) {
$title .= $row['title'] . "<br />";
$url .= $row['url'];
$description .= $row['description'] . "<br />";
}
echo "<h3><a href='$url'>$title</a><h3>
$description";
echo $pagination;

Share this post


Link to post
Share on other sites

It's doing exactly what you tell it to do. You have a loop where you loop through the database records. After that loop, you display one thing. It's doing exactly what you told it to do, you told it to only display the last record that it selected.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...