 | Welcome to Dnforum.com
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast and simple so please, join our community today!
If you have any problems with the registration process or your account login, please contact us. |  |
06-17-2005, 02:52 AM
|
#1 (permalink)
| | /DELUSER
Last Online: Today 03:15 AM Join Date: Apr 2004
Posts: 2,266
DNF$: 5,385 Location: New Zealand
Country: | Real Easy PHP/Java Query I have a site, eg www.house.com
I want one ad to show on every single page, except any page that has www.house.com/forum* in the URL.
For the pages that have www.house.com/forum* in the URL I want to show another ad.
I guess either javascript or PHP could do this.
eg.
Define URL
IF URL=www.house.com/forum*
Then
Display AD2
ELSE
Display AD1
I know how it should work, just not the actual code.
Help much appreciated!!!!
PS: Any questions about what I have said please ask, I really need this help 
__________________ PM me with your email address for a Free SEDO PRO Endorsement Code Want to be accepted into the Number 1 Domain Parking Program? Apply through me to Parked.com! |
| |
06-17-2005, 03:11 AM
|
#2 (permalink)
| | www.LOL.biz
Name: Daniel Last Online: Yesterday 08:09 PM Join Date: Apr 2004
Posts: 1,782
DNF$: 5,158 Location: .ro
Country: | Re: Real Easy PHP/Java Query Code: <script type="text/javascript">
//****************configuration **********************//
//string to look for
lookFor="www.house.com/forum";
//HTML to display when the string was NOT found -take care of the proper quotes embedding-
// do not add single quotes without addin a \ first
HTML1='<img src="http://www.mysolarsystem.com/images/jupiter.jpg">';
//HTML to display when the string was found
HTML2='<img src="http://www.mysolarsystem.com/images/saturn.jpg">';
//****************configuration ends here **********************//
w=location.href;
index=w.indexOf(lookFor);
if(index=-1){
//the current URL does not contain searched string
document.write(HTML1);
}
else{
//the current URL contains the searched string
document.write(HTML2);
}
</script> I hope this helps.
PS:
Java and javascript are extremely different...
Last edited by IT Web Team; 06-17-2005 at 03:32 AM.
|
| |
06-17-2005, 04:08 AM
|
#3 (permalink)
| | /DELUSER
Last Online: Today 03:15 AM Join Date: Apr 2004
Posts: 2,266
DNF$: 5,385 Location: New Zealand
Country: | Re: Real Easy PHP/Java Query Cheers man,
I dont think it is working though, because the ads themselves are java and I dont know how to edit them to be compatible with the above.
Some other guy suggested
<? if (eregi('www.house.com/forum', $_SERVER['HTTP_HOST'].'/'.$_SERVER['PHP_SELF'])) { ?>
Display AD2
<? } else { ?>
Display AD1
<? } ?>
But it only displays AD1, even when AD2 is meant to be displayed.
__________________ PM me with your email address for a Free SEDO PRO Endorsement Code Want to be accepted into the Number 1 Domain Parking Program? Apply through me to Parked.com! |
| |
06-17-2005, 04:25 AM
|
#4 (permalink)
| | www.LOL.biz
Name: Daniel Last Online: Yesterday 08:09 PM Join Date: Apr 2004
Posts: 1,782
DNF$: 5,158 Location: .ro
Country: | Re: Real Easy PHP/Java Query If you prefer PHP,here is the code.
The JavaScript( not Java!) method works as well, both tested. Code: <?
$lookFor="www.house.com/forum";
$url = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
if (eregi($lookFor, $url)) { ?>
Display AD2
<? } else { ?>
Display AD1
<? } ?> |
| |
06-17-2005, 05:00 AM
|
#5 (permalink)
| | /DELUSER
Last Online: Today 03:15 AM Join Date: Apr 2004
Posts: 2,266
DNF$: 5,385 Location: New Zealand
Country: | Re: Real Easy PHP/Java Query Awesome
I have it going now - thanks a lot!
__________________ PM me with your email address for a Free SEDO PRO Endorsement Code Want to be accepted into the Number 1 Domain Parking Program? Apply through me to Parked.com! |
| |
06-17-2005, 10:06 AM
|
#6 (permalink)
| | DNF Addict
Last Online: 06-25-2008 04:44 AM Join Date: Sep 2004
Posts: 1,787
DNF$: 0 Location: Geneva, Switz. | Re: Real Easy PHP/Java Query Quote: |
Originally Posted by IT Web Team The JavaScript(not Java!) method works as well, both tested. | Lol, I get this all the time! In fact, last birthday my wife even gave me a great big "Programming Java Applets" manual, and then was quite affronted when I tried to explain to her that I don't use Java and had no interest in learning how too. - "But you did that JavaScript course last summer and said it had been really useful to you?" 
__________________ Offers wanted on BXN.net! |
| |
07-13-2005, 03:38 AM
|
#7 (permalink)
| | /DELUSER
Last Online: Today 03:15 AM Join Date: Apr 2004
Posts: 2,266
DNF$: 5,385 Location: New Zealand
Country: | Re: Real Easy PHP/Java Query Any idea how to change the PHP version of this code, to include multiple URLs?
ie. abc.com/a.php and abc.com/b.php it doesnt display
But for any other abc.com address it will display?
Cheers
__________________ PM me with your email address for a Free SEDO PRO Endorsement Code Want to be accepted into the Number 1 Domain Parking Program? Apply through me to Parked.com! |
| |
07-13-2005, 10:12 AM
|
#8 (permalink)
| | Platinum Lifetime Member
Last Online: 10-22-2007 05:58 PM Join Date: Jul 2004
Posts: 455
DNF$: 1,655 Location: United States | Re: Real Easy PHP/Java Query all you'd have to do is change the $lookfor variable.
basically what the script is doing is just checking what the url that is being requested is, then compares the url against the lookfor variable, and does a simple if else statement.
easy to modify for any site.
__________________ Tyler Cruz schooled me in BW, so he won this until May 23rd, 2011 TylerCruz |
| |
07-19-2005, 01:30 PM
|
#9 (permalink)
| | Platinum Lifetime Member
Last Online: 04-18-2008 05:49 PM Join Date: Jun 2005
Posts: 524
DNF$: 2,486 | Re: Real Easy PHP/Java Query can u explain the code pleasE?
i m a newbie {learning php} and would like to know wt this code means Quote:
<?
$lookFor="www.house.com/forum";
$url = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
if (eregi($lookFor, $url)) { ?>
Display AD2
<? } else { ?>
Display AD1
<? } ?>
| |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| | | | All times are GMT -4. The time now is 05:18 AM.
Copyright @2001-2008 DNForum.com
|