How to paginate results

Hi there.

First off, I’m not a developer, i don’t know php. I know how to hunt and peck, and through searching websites I figure out how to get things done. but i absolutely don’t know how to code.

I’ve cobbled up some code to take a directory and display its contents. There’s a short backstory here.

Recently I migrated my forum from vbulletin to Xenforo (after being a vb customer since 2000) the migration didn’t pick up the smilies.

over 8 years this forum was up we had a ton of smilies. WAY too many. so i asked the admins to add a few back in. but i wawnted to show them all the smilies that were on the other site. So i came up with this.

this works fine. puts the image out for display as an anchor, puts the path in the text box so they can copy the source location so they can add it to a new smiley on the new forum.

everything is great, except, there are over 400 smilies in this directory, and as you can imagine this list gets very long.

I’d like to do one of two things.

  1. change this to a table. but really that’s not the right answer, it’ll still be way too long
  2. paginate these results. maybe to show 50 at a time, or even 100.

whatever the case, i need some help on how to display these results in a better, more efficient manner.

can someone give me some ideas?

here is my code

[php]<?php

$dirname = “smilies/”;
$images = glob($dirname."*");
foreach($images as $image) {

echo ’

click here to add a smilie

’;
}
?>[/php]

It really depends on what you mean by efficient.

  1. We can change it to a table and shorten the amount of HTML that’s produced (Efficient being less bytes per page)

  2. If you doing paging, you’re going to have to do it with jquery or javascript (you’ll see less smilies per page, but the code will still contain a lot of bytes to provide a smoother user experience).

  3. You can do a combination of 1 and 2.

Today, I actually added paging to my own website “www.unlocktheinbox.com” - take a look at the type right you’ll see it say Page 1 of 2 - I wanted to add more articles without making the page longer. 2 tables are rendered, but I set the display to none on the table I don’t want to show… Same amount of HTML but I’m just showing different data based on the page selected.

Sponsor our Newsletter | Privacy Policy | Terms of Service