PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   How-to Forum (http://www.phpdig.net/forum/forumdisplay.php?f=33)
-   -   Number of links found (http://www.phpdig.net/forum/showthread.php?t=367)

bloodjelly 01-08-2004 05:58 PM

Number of links found
 
Hi -

I'd like to grab the total number of links found from the results array. It seems to be under "result_message", but I can't figure out how to get it yet. Any ideas? Thanks.

Just thought I'd mention the way I'm searching the array...I think it's faulty. Check it out:
PHP Code:

while ($results['results'][$i]['weight']){
                    
// Add weight of results to total until loop finishes
                    
$total += $results['results'][$i]['weight'];
                    
$i++;
                } 

This adds the weights of the results but only the first 10. This is related to the first problem I think, because I can't figure out how to get all the results. Thanks again :)

Charter 01-09-2004 04:13 AM

Hi. In search_function.php is the following:
PHP Code:

$result_message stripslashes(ucfirst(phpdigMsg('results'))." $n_start-$n_end, $num_tot ".phpdigMsg('total').", ".phpdigMsg('on')." \\"".htmlspecialchars($query_string)."" ($search_time ".phpdigMsg('seconds').")"); 

The $num_tot variable holds the number of results returned from a search. If you want to return $num_tot try the following.

In search_function.php replace:
PHP Code:

if ($template == 'array' || is_file($template)) {
    
$phpdig_version PHPDIG_VERSION;
    
$t_mstrings compact('powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links');
    
$t_fstrings phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'template',$template);
    if (
$template == 'array') {
        return 
array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
    }
    else {
        
$t_strings array_merge($t_mstrings,$t_fstrings);
        
phpdigParseTemplate($template,$t_strings,$table_results);
    }


with the following:
PHP Code:

$my_num_results $num_tot;
if (
$template == 'array' || is_file($template)) {
    
$phpdig_version PHPDIG_VERSION;
    
$t_mstrings compact('my_num_results','powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links');
    
$t_fstrings phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'template',$template);
    if (
$template == 'array') {
        return 
array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
    }
    else {
        
$t_strings array_merge($t_mstrings,$t_fstrings);
        
phpdigParseTemplate($template,$t_strings,$table_results);
    }


Now <phpdig:my_num_results/> should be available for use in a template and hold the number of results returned from a search.

Remember to remove any "word" wrapping in the above code.

bloodjelly 01-09-2004 09:50 AM

Perfect - works great. Thanks a lot for the quick reply. :D


All times are GMT -8. The time now is 12:50 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.