Jump to content

help me out ;D


w32

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??
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.