![]() |
Need PHP basic help
Okay, pretty simple stuff but I'm not able to find out wtf doesn't work.
I need the "rid" from http://www.blah.com/gallery.php?rid=2000 to be added to each sponsor link. ie: http://www.blah.com/gallery.php?rid=2000 goes to http://www.sponsor.com/tour.php?rid=2000 And if I type a different "rid", it will automatically modify all the links. Currently, all pages are in .php and links look like this: http://www.sponsor.com/tour.php?rid= I'm sure I have something to add in the header in php. thanks! |
If I understand your need correctly this should work:
PHP Code:
-Tony |
Noob!
PHP Code:
|
PHP Code:
|
great, thanks guys
|
Another longer way to do it (which could have issues if your linking elsewhere off your site), but it would save time adding the code to each link... is just to get the page to open the original file as an input and go a preg_replace for all link tags adding ?rid=$rid to the end of the link values. Sure this is the longer way around and the page might load slightly slower, but hell I'm lazy and I don't want to spend the 3 secs it takes to do a search/replace on a page of code :P
Plus you ever seen the face of a graphic designer when they see "funny" code. They stop in their tracks with this strange look, then it... "what do I do with this"... |
Save the following to a file called fixlinks.php:
PHP Code:
PHP Code:
http://www.sponsor.com/tour.php?rid=1000 rid=1000 is your default code if someone forgets to add an rid= parameter to the url or it gets lost. Works on PHP 4.1 or later. Alternatively, in your .htaccess file put PHP Code:
PHP Code:
I haven't tested any of this. You'll be lucky if it works. Damn, the PHP highlighting colors are fugly on this board. and vBulleton mangles code. There is a \ in front of the .php and in front of .html in the .htacces file samples. you really will be lucky to get this to work. |
jesus what a fucking mess... man. if you want to do it.. in most cases the very first reply will work fine. If it DOESNT work, use the second one.. if you want to get confused and more than you wanted to deal with, try the other suggestions. Thing is, that the first one is the most tedious to code, but is most flexible. The second one will make it so that EVERY coded link on the page will go to the same place (defined by $url) not necessarily bad, but just not quite as flexible as doing it all by hand.
D |
yeah agreed that the first is the simplest, but thin of the pain when it comes to adding that code to each link and you have a front end with the main graphic split into 40~50+ linked images... aaah the pain :P
But yeah, do it which ever way, it gets you the same result in the end. |
how come scripting always comes in so small?
specifically php |
Quote:
|
Quote:
jDoG |
Quote:
This will work on PHP 4.1 or better: PHP Code:
|
| All times are GMT -7. The time now is 01:51 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123