homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Current Url in Variable?
dkin

10+ Year Member



 
Msg#: 3322266 posted 10:35 am on Apr 26, 2007 (gmt 0)

Ok this is my problem.

I have a script I am using as an include in many sites. It pulls info from a database and displays ads. Now every site that this is displayed on has an ad in the database and I dont want anyones ads showing on their own site.

I wrote this.

##$current = $_SERVER["HTTP_HOST"];
$current = $_SERVER['PHP_SELF'];

$lin = mysql_query("SELECT * FROM link order by id asc", $link) or die ("query 1: " . mysql_error());
echo '<li><h2>LinkWork</h2>'
. '<ul>';
while ($li = mysql_fetch_array($lin)) {
if ($current == $li['base'])
{
echo '';
}
else
{
echo '<li><a href="'.$li['web_url'].'" alt="'.$li['alt_tag'].'">'.$li['display'].'</a></li>';

}
}

The column base, is the base of a url eg. #*$!.com

So that is what I need to find, a php variable that gives me the current pages web address, but only up to the end of the com or org.

 

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3322266 posted 12:01 pm on Apr 26, 2007 (gmt 0)

you can use one of the $_SERVER [php.net] vars and then use parse_url() [php.net]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved