php - Limit fetch results by page -


this file included in index file, want not more 5 posts on page , under posts 1 2 3 4... , etc. (links next pages) , index.php?page=2 sorry bad grammar.

    <?php     if(isset($_get['post_edit'])) {     $p_id = $_get['post_edit'];      $p_query = mysql_query("select title, post posts id='$p_id'");     $p_array = mysql_fetch_array($p_query);     $title = $p_array['title'];     $post = $p_array['post'];     }     ?>      <?php     if(isset($_post['edit'])){         $title_edit = $_post['titleedit'];         $post_edit = $_post['postedit'];      if(empty($title) or empty($post)){         echo "<p>fields empty!</p>";         } else {         mysql_query("update posts set title='$title_edit', post='$post_edit' id='$p_id'");         echo "edit succesful!</br>";         header('location: index.php');     }     }     ?>      <?php     if(isset($_get['post_edit']) && !empty($_get['post_edit'])){     include 'edit_post.php';     } else {      ?>     <?php      $query = mysql_query("select * posts order date desc");         while($row = mysql_fetch_array($query)){       echo "<div class='poststitle'>";         echo "<div style='font-weight: bold;'>";             echo $row['title'];         echo "</div>";     echo "</div>";      echo "<div class='posts'>";         echo $row['post'];         echo "</br>";         echo "<hr>";          $user_name = mysql_query("select username users id = '".$row['user']."' ");         $user_name_array = mysql_fetch_array($user_name);             $post_id = $row['id'];          echo "posted by: <b>";         echo $user_name_array['username'];         echo "</b> | ";          echo "views: <b>";         echo $row['views'];         echo "</b> | ";          echo "posted on: ";         echo "<b>";         echo $row['date'];         echo "</b><hr>";      echo '</div>';      if (loggedin()){     if($user_level == 1){         echo "<div class='postoptions'>";         echo "<a href='index.php?post_edit=$post_id'><img src='img/optionicons/edit.png' width='15' height='15' alt='edit' /></a>";         echo "<a href='del_post.php?del=$post_id'><img src='img/optionicons/cancel.png' width='15' height='15' alt='delete' /></a>";         echo "</div>";         } else {         echo "";         }     } } } ?> 

select * table_name limit n, m

where n - number of limited rows , m(offset) = n * (page -1)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -