Jump to content


Photo

help me out ;D


  • Please log in to reply
1 reply to this topic

#1 w32

w32
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 10 July 2006 - 04:19 PM

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:
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
		}	
	
	}
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??

#2 robos99

robos99
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 10 July 2006 - 05:19 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users