Hi ,
my question is how to find the main domain and exclude other characters , for instance :
http://www.tarjome.org/something/blah_blah.php
and then convert to :
http://www.tarjome.org
i tried preg_replace but nothing useful came out
any suggestion would be appreciated
thanks
how to exclude and find the maiun domain address
Moderator: General Moderators
- EverLearning
- Forum Contributor
- Posts: 282
- Joined: Sat Feb 23, 2008 3:49 am
- Location: Niš, Serbia
Re: how to exclude and find the maiun domain address
Take a look at parse_url function in PHP Manual.
Re: how to exclude and find the maiun domain address
Thanks for ur nice solution
but i considered how to count similar pages :
I want to count referrer from websites but it's not important where of that domain they came to my site
e.g. : http://www.yours.com
http://www.yours.com/blah_blah
then the script count this 2 http://www.yours.com not 1 http://www.yours.com and 1 http://www.yours.com/blah_blah
this is my script
but i considered how to count similar pages :
I want to count referrer from websites but it's not important where of that domain they came to my site
e.g. : http://www.yours.com
http://www.yours.com/blah_blah
then the script count this 2 http://www.yours.com not 1 http://www.yours.com and 1 http://www.yours.com/blah_blah
this is my script
Code: Select all
$query = "SELECT url ,COUNT(rid) FROM ".$prefix."_referer GROUP BY url ORDER BY COUNT(rid) DESC LIMIT 0,".$ref;
$result2 = mysql_query($query) or die(mysql_error());
while($row2 = mysql_fetch_array($result2)){
$numrid =intval($row2['COUNT(rid)']);
$url =check_html($row2['url'], "nohtml");
$Domain = parse_url("$url");
$repurls = $Domain["host"];
$repurlsshort = str_replace("_", " ", $repurls);
if(strlen($repurlsshort) > 18) {
$repurlsshort = substr($repurls,0,20);
$repurlsshort .= "..";
}
echo $a.": <a href=\"http://".$repurls."\" target=\"new\">".$repurlsshort."</a><font color='red'><b>$numrid</b></font><br>";-
SidewinderX
- Forum Contributor
- Posts: 407
- Joined: Fri Jul 16, 2004 9:04 pm
- Location: NY
Re: how to exclude and find the maiun domain address
Use the LIKE keyword in your query.
Re: how to exclude and find the maiun domain address
similar data can be fetched but can not count them ?!
look at my above codes and example .. my main concern is how to count similar data
thanks
look at my above codes and example .. my main concern is how to count similar data
thanks
-
SidewinderX
- Forum Contributor
- Posts: 407
- Joined: Fri Jul 16, 2004 9:04 pm
- Location: NY
Re: how to exclude and find the maiun domain address
Well, perhaps rather than using the query to count, fetch the similar data as I suggested, then use mysql_num_rows to count the result set.
Re: how to exclude and find the maiun domain address
thanks.
for the last request can you show me in code .. ( please edit my previous codes that it can able to count similar data )
for the last request can you show me in code .. ( please edit my previous codes that it can able to count similar data )
-
SidewinderX
- Forum Contributor
- Posts: 407
- Joined: Fri Jul 16, 2004 9:04 pm
- Location: NY
Re: how to exclude and find the maiun domain address
Code: Select all
$domain = "yours.com";
$query = "SELECT `url` FROM ".$prefix."_referer WHERE `url` LIKE %".$domain."%";
$result = mysql_query($query);
$amount = mysql_num_rows($result);