Hello peeps!
I really need a pagination for this code:

<body>
<div class="myFiles-content">
<div id="myFiles-upload">
<table>
<tr>
<td class="login-form">
    <form action="index.php?page=user_upload2" method="post" enctype="multipart/form-data">
        <input class="button1" type="file" name="uploaded_file"><br>
        <input class="button1" type="text" name="description" maxlength="60" value="Description" onClick="this.value='';">
    <input class="button1" type="submit" value="Upload">
    </form>
</td>
</tr>
</table>
</div>
    </div><br>
<table cellpadding="0" cellspacing="0" border="0">
       <tr class="myFiles-thtable">
       <th class="myFiles-thtable-red" width="200"><p><font color="black">File</font></p></th>
       <th class="myFiles-thtable-red" width="200"><p><font color="black">Description</font></p></th>
       <th class="myFiles-thtable-red" width="200"><p><font color="black">Link</font></p></th>
       <th class="myFiles-thtable-red" width="150"><p><font color="black">Date</font></p></th>
       <th class="myFiles-thtable-red" width="50"><p><font color="black">#</font></p></th>
        </tr>
        
<?php 
$id = $_SESSION['loginid']; // login session.
$sql = "Select * from userfile2 where userid='$id' ORDER BY created desc;";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)) {
?>
<?php
$id = $_SESSION['loginid'];
?>
       <tr>
 
       <td width="200" class="files2-borderbottom"><p><font color="#000099"><a href="u/<?php echo $id ?>/<?php echo  $row['name']; ?>"><?php echo  $row['name']; ?></a></font></p>
       </td>
       <td width="200" class="files2-borderbottom" align="center"><p><?php echo $row['description']; ?></p></td>
       <td width="200" class="files2-borderbottom"><p><input type="text" value="www.xxxx.com/u/<?php echo $id ?>/<?php echo $row['name'];?>" class="button1"></p></td>
       <td width="150" class="files2-borderbottom" align="right"><p><?php echo $row['created']; ?></p></td>
       <?php $id = $row['id']; 
	   ?>
       
       <td width="50" class="files2-borderbottom"><a href="edit_files.php?deleteid=<? echo base64_encode($id);?>"><small> (delete)</small></a><a href="update.php?id=<? echo $row['id']; ?>"><small></small></a></td>
       </tr>
        <?php
	   }
	   ?>
       </Table>
       </body>
</html>

Its a list generated from mysql and i've tried to understand pagination for like months now. Cant do it. Its the last <tr> tag that echoes out he data.
I do not have money for this but i could offer you an FTP account with unlimited storage/bandwith pointed at your own ISL secured folder and also a sub domain if you'd want that.

I really hope someone can put together a pagination for this. If you do just PM me and the FTP account is yours! Unlimited space.

*crossing fingers*
Regards,
Sorcher

So, instead of listing all files for a user, you want to show (say) 10 files and below that links to the previous/next pages ?

Anyway, maybe this can help.

Did not understand one line of code in that topic u replyed with. It got nothing to do with my code.

I apologize if that sounded frustrating from my side. But i'm pretty tierd of searching.

Never mind. I'll combine the two when I get home.

I'd appreciate that allot. Just nod and i'll PM some FTP settings.

The following is adjusted to my test tables, so you'll have to replace some stuff. You can view the output of my file here.

<?php
  function createNavigation($current = 1, $total = 1, $enclose = 2, $endpoint = 2) {
	if ($current < 1)
		$current = 1;
	if ($total < 1)
		$total = 1;
	if ($current > $total)
		$current = $total;

	$front = array();
	$middle = array();
	$last = array();
	
	for ($i = 1; $i <= $endpoint; $i++)
		$front[] = $i;
	for ($i = $current - $enclose; $i <= $current + $enclose; $i++)
		$middle[] = $i;
	for ($i = $total - $endpoint + 1; $i <= $total; $i++)
		$last[] = $i;
	
	$nav = array_merge($front, $middle, $last);
	$nav = array_unique($nav, SORT_NUMERIC);
	
	$nav2 = array ();
	foreach ($nav as $val)
		if ($val > 0 && $val <= $total)
			$nav2[] = $val;
			
	$nav = array ();
	$prev = 0;		
	foreach ($nav2 as $val) {
		if ($val > $prev + 1)
			$nav[] = '..';

		if ($val == $current)
			$nav[] = "<span class='current'>$val</span>";
		else
			$nav[] = "<a href='?page=$val'>$val</a>";

		$prev = $val;
	}
	
	return implode(' ', $nav);
  }

  include 'defines.inc.php';
  $link = @mysql_connect(HOST, USER, PASS);
  @mysql_select_db(DATABASE);
?>
<html>
 <body>
  <div class="myFiles-content">
   <div id="myFiles-upload">
    <table>
     <tr>
      <td class="login-form">    
       <form action="index.php?page=user_upload2" method="post" enctype="multipart/form-data">        
        <input class="button1" type="file" name="uploaded_file"><br>        
        <input class="button1" type="text" name="description" maxlength="60" value="Description" onClick="this.value='';">    
        <input class="button1" type="submit" value="Upload">    
       </form>
      </td>
     </tr>
    </table>
   </div>    
  </div>
  <br>
  <table cellpadding="0" cellspacing="0" border="0">       
   <tr class="myFiles-thtable">       
    <th class="myFiles-thtable-red" width="200"><p><font color="black">File</font></p></th>       
    <th class="myFiles-thtable-red" width="200"><p><font color="black">Description</font></p></th>       
    <th class="myFiles-thtable-red" width="200"><p><font color="black">Link</font></p></th>       
    <th class="myFiles-thtable-red" width="150"><p><font color="black">Date</font></p></th>       
    <th class="myFiles-thtable-red" width="50"><p><font color="black">#</font></p></th>        
   </tr> 
   <?php 
    $id = -1; 
    // login session.
    
    $sql = "Select count(*) as count from countries";
    $result = mysql_query($sql);
    $row = mysql_fetch_assoc($result);
    $numresults = $row['count'];
    mysql_free_result($result);
    
    $itemsperpage = 2;
    $numpages = ceil($numresults / $itemsperpage);
    $currentpage = isset($_GET['page']) ? $_GET['page'] : 1;

    $from = ($currentpage - 1) * $itemsperpage;
    $to = $from + $itemsperpage;

    $sql = "Select * from countries limit $from,$to";
    $result = mysql_query($sql);
    
    while ($row = mysql_fetch_assoc($result)) 
    {
     $id = -1;
   ?>       
   <tr>        
    <td width="200" class="files2-borderbottom"><p><font color="#000099">
     <a href="u/<?php echo $id ?>/<?php echo  $row['name']; ?>"><?php echo  $row['name']; ?></a>
    </font></p></td>       
    <td width="200" class="files2-borderbottom" align="center"><p><?php echo $row['description']; ?></p></td>       
    <td width="200" class="files2-borderbottom"><p>
     <input type="text" value="www.xxxx.com/u/<?php echo $id ?>/<?php echo $row['name'];?>" class="button1">
    </p></td>       
    <td width="150" class="files2-borderbottom" align="right"><p><?php echo $row['created']; ?></p></td>       
    <?php $id = $row['id']; ?>        
    <td width="50" class="files2-borderbottom"><a href="edit_files.php?deleteid=<? echo base64_encode($id);?>"><small> (delete)</small></a><a href="update.php?id=<? echo $row['id']; ?>"><small></small></a></td>       
   </tr>        
   <?php	   
    }	   
   ?>       
  </Table> 
  <?php
    echo createNavigation($currentpage, $numpages);
  ?>      
 </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.