PhpDig.net

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

Reply
 
Thread Tools
Old 02-27-2004, 06:35 PM   #1
tomas
Orange Mole
 
Join Date: Feb 2004
Posts: 47
Search Template/Array

hi charter,

1) using search with template - how to include a drop-down
menu to select different parts (paths) of website to be searched
2) using search with array only

i tried several solutions - all of them work well - but i don't like
them at all :-)
so - you would do me a great favour - posting two COMPLETE solutions - the way YOU would do it

thanks again
tomas
tomas is offline   Reply With Quote
Old 02-28-2004, 11:24 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
>> i tried several solutions - all of them work well - but i don't like them at all...

Hi. Just curious, if they all work well, why don't you like them? :confused:

Anyway, the following was not tested much so you'll need to check it.

First in function_phpdig_form.php replace the following:
PHP Code:
$result['form_head'] = "<form action='$result_page' method='get'>
<input type='hidden' name='site' value='$site'/>
<input type='hidden' name='path' value='$path'/>
<input type='hidden' name='result_page' value='$result_page'/>
"

with the following:
PHP Code:
$dropdown_flag 0;
$relative_script_path '.';
if (
is_file("$relative_script_path/includes/connect.php")) {
    include 
"$relative_script_path/includes/connect.php";
}
else {
    die (
"Unable to find connect.php file for dropdown menu.\n");
}
if (isset(
$site) && is_numeric($site) && ($site 0)) {
    
$site = (int) $site;
    
$dd_query mysql_query('SELECT DISTINCT path FROM '.PHPDIG_DB_PREFIX.'spider WHERE site_id = '.$site.' AND path != ""',$id_connect);
    if (@
mysql_num_rows($dd_query) > 0) {
        
$result['form_head'] = "<form action='$result_page' method='get'>
        <input type='hidden' name='site' value='$site'/>
        <input type='hidden' name='refine' value='1'/>
        <input type='hidden' name='result_page' value='$result_page'/>"
;
        
$result['form_dropdown'] = "Select a path to search: <select name='path'>";
        while (
$dd_data mysql_fetch_array($dd_query)) {
            if (
$path == $dd_data['path']) {
                
$result['form_dropdown'] .= "<option value='".$dd_data['path']."' selected>".$dd_data['path']."</option>";
            }
            else {
                
$result['form_dropdown'] .= "<option value='".$dd_data['path']."'>".$dd_data['path']."</option>";
            }
        }
        
$result['form_dropdown'] .= "</select> <a href=\"$result_page\">Restart</a>";
    }
    else {
        
$dropdown_flag 1;
    }
}
else {
    
$dropdown_flag 1;
}
if (
$dropdown_flag == 1) {
    
$dd_query mysql_query('SELECT site_id,site_url FROM '.PHPDIG_DB_PREFIX.'sites',$id_connect);
    
$result['form_head'] = "<form action='$result_page' method='get'>
    <input type='hidden' name='path' value='$path'/>
    <input type='hidden' name='refine' value='1'/>
    <input type='hidden' name='result_page' value='$result_page'/>"
;
    
$result['form_dropdown'] = "Select a site to search: <select name='site'>";
    while (
$dd_data mysql_fetch_array($dd_query)) {
        
$result['form_dropdown'] .= "<option value='".$dd_data['site_id']."'>".$dd_data['site_url']."</option>";
    }
    
$result['form_dropdown'] .= "</select> <a href=\"$result_page\">Restart</a>";

Next in search.php add the indicated line:
PHP Code:
extract(phpdigHttpVars(
     array(
'query_string'=>'string',
           
'refine'=>'integer',
           
'refine_url'=>'string',
           
'site'=>'integer',
           
'limite'=>'integer',
           
'option'=>'string',
           
'lim_start'=>'integer',
           
'browse'=>'integer',
           
'path'=>'string'
           
)
     ));

if (
$site <= 0) { $query_string ""; } // add this line here

phpdigSearch($id_connect$query_string$option$refine,
              
$refine_url$lim_start$limite$browse,
              
$site$path$relative_script_path$template); 
Then in a template, say the phpdig.html file, add <phpdig:form_dropdown/> like so:
Code:
 <tr>
 <td class="greyForm">
 <phpdig:form_radio/>
 </td>
 </tr>

 <tr>
 <td class="greyForm">
 <phpdig:form_dropdown/>
 </td>
 </tr>

</table>
<phpdig:form_foot/>
If you want to use an array $varname['form_dropdown'] would also be available using this code.

When you call search.php you'll get a drop down of sites to search, and then you'll get a drop down of paths within that site to search.

Of course, TMTOWTDI and 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
Reply


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
explode & array issues Graphicgreen Coding & Tutorials 1 03-29-2007 12:35 PM
Help using output as Array function ehdesign How-to Forum 0 09-16-2006 05:32 AM
Array variables in MySQL UPDATES peterl3233 Coding & Tutorials 4 11-10-2005 08:59 PM
how to use the "phpdigSearch" array flanders How-to Forum 2 10-06-2004 06:07 AM


All times are GMT -8. The time now is 04:23 PM.


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