Jump to content

Archived

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

w32

help me out ;D

Recommended Posts

So yeah I'm trying to make some simple forums of my own, and I'm having a bit of trouble with the pagination. After you post you should be redirected to the page in which you posted, and specifically to your post #. And they way I did it, it worked, except for one thing. You're only redirected to the page in which you posted, but if your post is in a new page, the redirection will not take you there.

Here's a bit of the pagination, it's a for loop:
[code]
for($i=1; $i<=$page_total; $i++)
{
if(($p)==$i)
    {
  echo $i;
}
else
    {
  ?>
  <a href="<?php $PHP_SELF; ?>?id=<?php echo $_GET['id']; ?>&p=<?php echo $i; ?>"><?php echo $i; ?></a>
  <?php
}

}
[/code]
So I want to add another attribut to that link. I want to add a '&st' attribute, that will have the value of a variable, it's the limit of the posts to be displayed. But if I put it in, every link has the same value.
My question is can I make a loop to have that variable be added another variable so each link in the navigaton has its own limit? Can I have a for loop inside another for loop??

Share this post


Link to post
Share on other sites
You can put another for loop within a for loop. But realize that with a nested for loop, your inner loop is going to run on every iteration of the outside loop. Not sure if that's what you're going for or not....if it is then there ya go.

FYI, you don't really need to keep jumping in and out of PHP for the link construction. You can echo html just fine, you only need to escape the quotes, or use single quotes for the html tags, but I seem to recall hearing that single quotes within an html tag was not xhtml compliant, so take it or leave it.

Share this post


Link to post
Share on other sites

×

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.