Forum Moderators: coopster

Message Too Old, No Replies

Adding Varible to $php_self

is it possible?

         

havoc

5:42 am on Jul 12, 2004 (gmt 0)

10+ Year Member



Hey there i am currently writing a script where i need a varible page number system.

There are two ways the pages come up , under a gallery or catergory. One page controls the whole lot and since page numbers comes in all sections i have to setup varible page numbers. The problem is i am trying to add 1 extra varible to the $php_self command and it isn't working.

for eg: i go to this catergory

"index.php?mode=thumbs&catergory=pics"

i need to add page number to the end of this when the numbering starts.

i have tried <a href=\"$php_self" . "&page=$pageno\">$pageno </a> this produced - "index.php&page=1"

i tried making a varible and adding it too.
$link = $php_self;
$link = $link . "&page=$pageno";
this also produced "index.php&page=1"

Is there any way i can add my page to the end of the url?
the end result would look something like
"index.php?mode=thumbs&catergory=pics&page=2"

rlkanter

5:51 am on Jul 12, 2004 (gmt 0)

10+ Year Member



printf( "<a href=\"%s?mode=thumbs&catergory=pics&page=%d\">%d</a>", $_SERVER['PHP_SELF'], $pageno, $pageno);

havoc

6:10 am on Jul 12, 2004 (gmt 0)

10+ Year Member



i need to add the Page to the $php_self
the reason why i cant go <a href="$php_self?mode=thumbs&catergory=pics&page=2">$pageno</a>
is that there can also be a result such as "$php_self?mode=thumbs&gallery=Cheesewheels"

One is a catergory and one is gallery.

Which is why when i grab $php_self i need to add the page=2 to the end of the $php_Self ... i cant hard code in the "?mode=thumbs&catergory=pics". i hope that makes sense.

i guess i could just make it so both varibles are in there but it would be messy.

Thanks for the above reply though. :)

rlkanter

7:28 am on Jul 12, 2004 (gmt 0)

10+ Year Member



I'm not sure I'm understanding why you're trying to do, but if mode and catagory are variables as well, I'd use them as such. Why not try something like:

printf( "<a href=\"%s?mode=%s&catergory=%s&page=%d\">%d</a>", $_SERVER['PHP_SELF'], $_GET['mode'], $_GET['catergory'], $pageno, $pageno);

[ edit - a few typos fixed, guess it's late :) ]

havoc

9:44 am on Jul 12, 2004 (gmt 0)

10+ Year Member



ok this makes more sense i think .. i will give it a go tonight.

but what i was originally trying to so i take the current value of $php_self which could be a variety of things
eg "index.php?mode=thumbs&catergory=pics"
or "index.php?mode=thumbs&gallery=pics"

and just plop a &page=$pageno to the value of $php_self.

if i have to split it all up i will do that

havoc

12:40 pm on Jul 12, 2004 (gmt 0)

10+ Year Member



I figured out a completely different way to do it :)

Netizen

9:02 pm on Jul 12, 2004 (gmt 0)

10+ Year Member



Or

printf('<a href="%s&page=%d">%d</a>',$_SERVER['REQUEST_URI'],$pagenum,$pagenum);

should work.