Jump to content

Help with simple PHP search script


taboo

Recommended Posts

the code:

<html> 
<head> 
<title>Domain Keyword Search</title>

<body>

<center>
<?php 

if(strlen($_POST['submit']) > 0) 
{ 


    $domains     = $_POST['domains']; 
    $search     = $_POST['search']; 
     
    foreach(explode("\n", $domains) as $value) 
    { 
        if(eregi($search, $value)) 
        { 
            echo $value . '<br />'; 
        } 
    } 
} 

?> 
<form action="<?=$_SERVER['PHP_SELF']?>" method="post"> 
    <textarea name="domains" rows="15" cols="60"></textarea><br /> 
    <textarea name="search" value="" rows="10" cols="60"></textarea><br /> 
    <input type="submit" name="submit" value="submit" /> 
</form>
</center>

</body>
</html>  

 

This script is for domainers who want to search a list of domains for keywords. However atm I can only figure out how to search 1 phrase at a time. Instead I wish to be able to input several terms in the textbox that would be seperated by each line.

 

example in the top box I would have something like:

americanbank.com

travelagency.com

airlinecompany.com

randomstuff.com

etc.

 

And it the second box I would want to have multiple search terms like:

bank

airline

 

Then the output of course would only show these domains from the list:

americanbank.com

airlinecompany.com

 

 

What would I need to add to have multiple search queries like this?

 

Thanks for your help.

Link to comment
https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/
Share on other sites

You can have any no of textfields required depending on,in how many ways u want to user to search.For instance search by category,search by name or search by price(in case of some other example).Accordingly you provide so many text fileds and optimize the query to search from the database accordingly.

The thing is I'm not searching from a DB, just text that I input...

 

The script currently will only search for 1 keyword, I want to search for 10+ keywords against a list of 1000+ domain names at a time.

 

I want to be able to do this by typing each individual phrase into a textbox seperated by returns or commas... thnx again

yea here is the script in action

 

http://net41.com/scripts/find3.php

 

input this in the first box:

americanbank.com

travelagency.com

airlinecompany.com

randomstuff.com

etc.

 

And input this in the second box:

bank

 

Now you will see it found the only bank domain... However try inputing more than 2 keywords, and it wont bring up any results. It is searching for the entire query, rather than multiple queries... Does it make more sense now?

 

so the foreach loop is working, but I am just missing how to seperate individual queires from a list...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.