Jump to content

page system


quickstopman

Recommended Posts

her guys im currently trying to make a system of post

and i don't want all the posts on one page

i have some php that limits how many articles are shown

but it doesn't make the pages needed to view the other articles

here is the code

<?php
   include 'header.php';
   //connect to and select db
   $conn = mysql_connect('localhost','user','password') or die(mysql_error());
   $db = mysql_select_db('pokebash_users',$conn) or die(mysql_error());
   
   //get a list of the info from the table to make the linkies
   $page = (isset($_GET['page']))?$_GET['page']:1; // page number

   $X = ($page - 1);
   $Y = (5 * $page);

   $sql = "select * from news ORDER BY id desc Limit $X,$Y ";
   $result = mysql_query($sql, $conn) or die(mysql_error());
   // for each row fetched from the results...  
echo "<table align='center' width='100%'>"; 
   while ($list = mysql_fetch_array($result)) {
       //make the custom linkie
       echo "
<tr height='70px' width='500px'>
<td><a href='post.php?id={$list['id']}'>{$list['topic']}</a></td><td>By: {$list['user']}</td><td>At: {$list['time']} </td>
</tr>

"; 
   } // end while
echo "</table>";
if (
   // if the user clicked on a linkie and therefore an id exists (the is_numeric is a basic security precaution) ...
   if (is_numeric($_GET['id'])) {
      // for easier var syntax handling
      $id = $_GET['id'];
       
       
      $sql = "select topic from news where id = '$id'";
      $result = mysql_query($sql, $conn) or die(mysql_error());

      $userfound = mysql_num_rows($result);
      if ($userfound) {
         $user = mysql_fetch_array($result);

      } // end if found
   } // end if there was a linkie clicked
?>

Link to comment
https://forums.phpfreaks.com/topic/51334-page-system/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.