Hello,
I am making a Group feature similar to the one Facebook has, What I am trying to do is add a pagination to the comments so there is not so many comments on the one status update displaying so far so good besides one thing When the user clicks next it will change every post on the group to the second page :/
How can I modify the below code to only update a certain post that has had the next clicked.
Here's the code(yes code is messed up working on this also)
<br /><br />-- July 18th, 2014, 12:26 pm --<br /><br />Anyone
I am making a Group feature similar to the one Facebook has, What I am trying to do is add a pagination to the comments so there is not so many comments on the one status update displaying so far so good besides one thing When the user clicks next it will change every post on the group to the second page :/
How can I modify the below code to only update a certain post that has had the next clicked.
Here's the code(yes code is messed up working on this also)
Code:
Advertisement
Hello,
I am making a Group feature similar to the one Facebook has, What I am trying to do is add a pagination to the comments so there is not so many comments on the one status update displaying so far so good besides one thing When the user clicks next it will change every post on the group to the second page :/
How can I modify the below code to only update a certain post that has had the next clicked.
Here's the code
PHP Code:
<body>
<?php
?>
<?php
require_once ("/../core/connection.php");
require_once ("/../core/group_functions.php");
$fetch_clan_posts_query = $db->query("SELECT * FROM " . TABLE_PREFIX . "groups_posts" . " WHERE group_url='$get_group_url' ORDER BY post_id DESC LIMIT 5");
function custom_pagination($page, $totalpage, $link, $show) //$link = '&page=%s'
{
//show page
if($totalpage == 0)
{
return 'Error Fetching Data return = 0 of 0<br>';
} else {
$nav_page = '<div class="navpage"><span class="current">Page '.$page.' of '.$totalpage.': </span>';
$limit_nav = 3;
$start = ($page - $limit_nav <= 0) ? 1 : $page - $limit_nav;
$end = $page + $limit_nav > $totalpage ? $totalpage : $page + $limit_nav;
if($page + $limit_nav >= $totalpage && $totalpage > $limit_nav * 2){
$start = $totalpage - $limit_nav * 2;
}
if($start != 1){ //show first page
$nav_page .= '<span class="item"><a href="'.sprintf($link, 1).'"> [1] </a></span>';
}
if($start > 2){ //add ...
$nav_page .= '<span class="current">...</span>';
}
if($page > 5){ //add prev
$nav_page .= '<span class="item"><a href="'.sprintf($link, $page-5).'">«</a></span>';
}
for($i = $start; $i <= $end; $i++){
if($page == $i)
$nav_page .= '<span class="current">'.$i.'</span>';
else
$nav_page .= '<span class="item"><a href="'.sprintf($link, $i).'"> ['.$i.'] </a></span>';
}
if($page + 3 < $totalpage){ //add next
$nav_page .= '<span class="item"><a href="'.sprintf($link, $page+4).'">»</a></span>';
}
if($end + 1 < $totalpage){ //add ...
$nav_page .= '<span class="current">...</span>';
}
if($end != $totalpage) //show last page
$nav_page .= '<span class="item"><a href="'.sprintf($link, $totalpage).'"> ['.$totalpage.'] </a></span>';
$nav_page .= '</div>';
return $nav_page;
}
}
//using
if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$result = $db->query("SELECT count(*) AS total FROM spud_groups_posts WHERE group_url='$get_group_url' ORDER BY post_body,post_id DESC");
$rows = $db->fetch_array($result);
$show = 10; //Show 5 result per page
$totalpage = ceil($rows['total'] / $show); //Total page
$start = ($page * $show) - $show; //Start result
$fetch_updates = $db->query("SELECT * FROM spud_groups_posts WHERE group_url='$get_group_url' ORDER BY post_id DESC LIMIT $start, $show") or die ('sss');
while($fetch_updates_array = $db->fetch_array($fetch_updates)) {
$post_id_row = $fetch_updates_array['post_id'];
$posted_by = $fetch_updates_array['posted_by'];
$posts_table = $fetch_updates_array['post_body'];
$escape_post_id_row = $db->escape_string($post_id_row);
echo("<br>" . "<a href=''> $posted_by </a>" . "<br>" . $posts_table);
echo "<br>
<form action='' method='POST'>
<input type='text' name='comment_post' class='comment_post' placeholder='Write A Comment'>
<input type='hidden' name='post_id_value' id='post_id_value' class='post_id_value' value='$post_id_row'>
</form>
";
$select_comments = $db->query("SELECT * FROM " . TABLE_PREFIX . "groups_comments WHERE post_id='$escape_post_id_row'");
$dbc = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("spud_gaming") or die(mysql_error());
$start = 0;
$limit = 5;
if(isset($_GET['start']))
{
$start = @mysql_real_escape_string(trim($_GET['start']));
}
if(is_numeric($start) === false)
{
$start = 0;
}
$query = "select * from spud_groups_comments WHERE post_id='$post_id_row' limit ".$start.", ".$limit;
$result = @mysql_query($query);
?>
<div style="width: 20%;">
<?php
if($start > ($limit - 2))
{
echo '<a href="?start='.($start - ($limit - 1)).'"><<previous</a> ';
}
if(@mysql_num_rows($result) > ($limit - 1))
{
echo '<a href="?start='.($start + ($limit - 1)).'" style="float: right;">next>></a>';
}
echo "</div>";
$i = 0;
while($row = @mysql_fetch_array($result))
{
if($i == 5)
{
break;
}
$i ++;
echo "<div>".$row['post_id'].") ".$row['post_body']."</div>";
}
echo "<div class='update_comments'>";
echo "</div>";
echo "
<br>
__________________________<br>
";
}
//Show pagination
echo custom_pagination($page, $totalpage, 'index.php?gname=first&page=%s', $show);
if($db->num_rows($fetch_clan_posts_query)){
echo '<ul id="records">';
while($fetch_clan_posts_array = @$db->fetch_array($fetch_clan_posts_query)){
}
}
//We have done everything we need to do we can now exit and not execute anything beyond this point
?>







