Log in

View Full Version : Related search terms issues



tgallagher26
05-04-2009, 04:31 PM
OK so I own a meta search engine.

I have successfully obtained the correct code to get related search terms to list on my site from MSN Live.

The code I am using is

<?php
$html2 = file_get_html("http://search.live.com/results.aspx?q=".$myurl);
foreach($html2->find('div[class=qscolumn]') as $related)
foreach($related->find('li') as $related2)

if($related2 == "" || (empty
($related2))) {echo 'No related search terms found.';}
else {echo '<a href="http://kywordpro.com/txt/1/10/' . $related2->plaintext . '.html">' . $related2->plaintext . '</a><br />';}
?>

The first problem I am having is when no related search terms are found its not puting 'No related search terms found.' on the site here is example page of this (http://kywordpro.com/txt/1/10/sr25m+sniper.html).

The second problem is I need to replace all the spaces in the related search terms with "+" and remove the extra space at the end of the related search term.
Here is a example page (http://kywordpro.com/txt/1/10/Jacinda+Barrett.html) which shows actual related search terms.

Thanks for any help I can get.
Tim...

Nile
05-04-2009, 05:18 PM
I have the solution for your space problem, not the other one thought:


<?php
$html2 = file_get_html("http://search.live.com/results.aspx?q=".$myurl);
foreach($html2->find('div[class=qscolumn]') as $related) {
foreach($related->find('li') as $related2) {
if(empty($related2)) {
echo 'No related search terms found.';
} else {
echo '<a href="http://kywordpro.com/txt/1/10/' . str_replace(" ", "+", trim($related2->plaintext)) . '.html">' . trim($related2->plaintext) . '</a><br />';
}
}
}
?>

tgallagher26
05-05-2009, 09:31 PM
I am still having a problem when no related search terms are found its not puting 'No related search terms found.' on the site here is example page of this.

If anyone has advice on fixing this I would be greatful.