• Welcome to New Hampshire Underground.
 

News:

Please log in on the special "login" page, not on any of these normal pages. Thank you, The Procrastinating Management

"Let them march all they want, as long as they pay their taxes."  --Alexander Haig

Main Menu

PLN site getting done

Started by aries, December 21, 2006, 02:06 PM NHFT

Previous topic - Next topic

aries

#45
Quote from: Beavis on February 15, 2007, 12:00 AM NHFT
That's scary.

:p I've got an estimate of 2 hours to go before I figure out how to generate a list of pages.

edit:
OH MY GOD I DID IT
I AM SO HAPPPY.
Pagination has been my enemy ever since I first wrote my tagboard script. I couldn't figure it out. I know most of you guys don't speak PHP but I'm so ecstatic about this I have to share:

I set up the option to view a certian page like this:


//count the number of lines in the database
$count1count(file($entryfile));
if(isset(
$_GET['show'])) {
$show $_GET['show'];
$showst1 $show-$showposts;
$Array array_splice(file($entryfile), $show5);$Array array_reverse($Array); }


Then I had it generate a list of links based on that, at the bottom of the finally generated page:


for ($x=0$x<$count1$x+=$showposts) {
echo 
"<a href=\"".$_SERVER['PHP_SELF']."?show=$x\">page $x</a>"; }


That was it. It was so simple. It hit me and I just went like "wait, would that work?" ... and it did... and my heart skipped a beat. Told you guys I love simple solutions.

That's it for tonight. Too much adrenaline for 2 in the morning. I need to take a step back tomrorow. I may actually develop this into a larger-scale, more polished and functional project, and release it.

error

It works, but it's got potential security problems. Untrusted input and all that.

aries

Quote from: Beavis on February 15, 2007, 01:57 AM NHFT
It works, but it's got potential security problems. Untrusted input and all that.

I edited out the unimportant bit - if(!is_numeric($show)) { echo "show must be an integer."; }

Other than that I don't see where you could see any security problems with that.

error

Quote from: aries on February 15, 2007, 02:14 AM NHFT
Quote from: Beavis on February 15, 2007, 01:57 AM NHFT
It works, but it's got potential security problems. Untrusted input and all that.

I edited out the unimportant bit - if(!is_numeric($show)) { echo "show must be an integer."; }

Other than that I don't see where you could see any security problems with that.

That was the important bit.

aries

Quote from: Beavis on February 15, 2007, 02:17 AM NHFT
That was the important bit.

:P well for the sake of demonstrating how it works, I left it out because it's nonessential.

error

Quote from: aries on February 15, 2007, 02:29 AM NHFT
Quote from: Beavis on February 15, 2007, 02:17 AM NHFT
That was the important bit.

:P well for the sake of demonstrating how it works, I left it out because it's nonessential.

I'm sure everyone else on this board could have done without the colorful -- but completely incomprehensible -- demonstration. ;D