PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 01-08-2004, 05:58 PM   #1
bloodjelly
Purple Mole
 
Join Date: Dec 2003
Posts: 106
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

Last edited by bloodjelly; 01-08-2004 at 09:46 PM.
bloodjelly is offline   Reply With Quote
Old 01-09-2004, 04:13 AM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
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.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-09-2004, 09:50 AM   #3
bloodjelly
Purple Mole
 
Join Date: Dec 2003
Posts: 106
Perfect - works great. Thanks a lot for the quick reply.
bloodjelly is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help : no links found Danydan Troubleshooting 2 07-12-2004 11:23 PM
Another: links found : 1 majestique Bug Tracker 11 07-12-2004 12:19 AM
0 links found, yes, another one juzzi Troubleshooting 5 07-05-2004 07:31 AM
links found : 0 w/ example squatty Troubleshooting 3 06-21-2004 05:00 AM
Links found: 1 CafeenMan Troubleshooting 10 05-12-2004 08:35 PM


All times are GMT -8. The time now is 06:25 PM.


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