taboo Posted February 11, 2008 Share Posted February 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/ Share on other sites More sharing options...
aschk Posted February 11, 2008 Share Posted February 11, 2008 Can you give an example of what you mean by "multiple search queries". As far as I can see you're doing exactly what you want at the minute... Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-463880 Share on other sites More sharing options...
rameshfaj Posted February 11, 2008 Share Posted February 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-463900 Share on other sites More sharing options...
taboo Posted February 11, 2008 Author Share Posted February 11, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-464377 Share on other sites More sharing options...
phpSensei Posted February 11, 2008 Share Posted February 11, 2008 str_replace("\n",",<br>",$keyword); I am just guessing, I have no clue what your asking for. Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-464385 Share on other sites More sharing options...
taboo Posted February 11, 2008 Author Share Posted February 11, 2008 I am just guessing, I have no clue what your asking for. What did I not explain properly? Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-464432 Share on other sites More sharing options...
phpSensei Posted February 12, 2008 Share Posted February 12, 2008 I am just guessing, I have no clue what your asking for. What did I not explain properly? Multiple Search Queries, and you say your not searching a DB Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-464433 Share on other sites More sharing options...
resago Posted February 12, 2008 Share Posted February 12, 2008 is your foreach loop working as you expect? you might want to print what its getting for $value.I'm not sure enters in text boxes come through as \n Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-464439 Share on other sites More sharing options...
taboo Posted February 12, 2008 Author Share Posted February 12, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/90481-help-with-simple-php-search-script/#findComment-464587 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.