I am fairly new to PHP but have created numerous web databases in other languages for my employer.
I am branching out and teaching myself PHP and MySQL.
so far I have created a simple web database (add, list, search and edit) that searches for a keyword in multiple fields BUT what I now want is to enter multipe words in the same field and have teh server run these words through multiple fields.
I take it I need to parse the days and then run the search for each independantly....any pointers where to begin?
Thanks
multiple keyword search
Moderator: General Moderators
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Not sure if I got it rigth, but try something like this:
The output:
Note this code won't solve your problem but it is a way to show you how you can handle it...
Hope that helps... let us know if it doesn't
Cheers,
Scorphus.
Code: Select all
<?php
function runEachWordThroughMultipleFields ($keyword) {
// Yoy do your job here...
echo 'running ', $keyword, "...\n"; // print the keyword for example purposes
return;
}
$multipleWords = "word1 word2 word3 word4"; // separated by space ' '
$keywords = explode(' ', $multipleWords); // [url=http://www.php.net/explode]explode info[/url]
foreach ($keywords as $value) { // [url=http://www.php.net/foreach]foreach info[/url]
// run a function:
runEachWordThroughMultipleFields($value);
// or/and do other things...
}
?>Code: Select all
running word1...
running word2...
running word3...
running word4...Hope that helps... let us know if it doesn't
Cheers,
Scorphus.