A php search engine that only shows results that match entire serch string
I have set up a dreamweaver search engine through php and a fulltext search (WHERE MATCH (....) AGAINST (...). However, when someone inputs more than one word into the search form, the search engine churns out results that only have one of those words. How do I get it to only show results that have all the search string words inside? (or, at least, how do I get those results to show up at the top?)
I have seen some advice (here) that uses php code to process the search query, divide up the words, and place a BOOLEAN '+' between each of the words. By doing this, the search engine will only show results that fully match all the terms.
My problem is that I do not know how to put this code into my Dreamweaver-created code.
My dreamweaver created code:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$form_rsSearch = "-1";
if (isset($_get['search'])) {
$form_rsSearch = $_get['search'];
mysql_select_db($database_dataConnect, $dataConnect);
$query_rsSearch = sprintf("SELECT title, content FROM encyclopedia WHERE MATCH (title, content) AGAINST (%s)", GetSQLValueString($form_rsSearch, "text"));
$rsSearch = mysql_query($query_rsSearch, $dataConnect) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);
$input_rsSearchResults = "-1";
if (isset($_GET['search'])) {
$input_rsSearchResults = $_GET['search'];
mysql_select_db($database_EMdataConnect, $dataConnect);
$query_rsSearchResults = sprintf("SELECT title, content FROM encyclopedia WHERE MATCH(title, content) AGAINST(%s)", GetSQLValueString($input_rsSearchResults, "text"));
$rsSearchResults = mysql_query($query_rsSearchResults, $dataConnect) or die(mysql_error());
$row_rsSearchResults = mysql_fetch_assoc($rsSearchResults);
?>
and the code the website (link above) gives is:
function search(String $search_string) {
//strip Boolean search characters out of search string
$search_string = string_replace($search_string,"+","");
$search_string = string_replace($search_string,"-","");
$search_string = string_replace($search_string,"*","");
//split the search string up into an array of words
Array $tokenized_search = split($search_string, " ");
//init an empty final search string
String $processed_search = "";
//for each word in the search, wrap it
//with an + and * character and then append
//it to the processed_search variable
foreach($tokenized_search as $token) {
$processed_search+="+"+$token+"* ";
//build the sql for the query and query the DB
String $db_query = "select id, description
from product_descriptions
where MATCH(description)
AGAINST ('"+$processed_search+"' IN BOOLEAN MODE)";
Array results = execute_database_query($db_query);
return results;
If anyone can instruct me on the correct way to go about this, I would be very much obliged.
Thank you,
YWSW
Don't use the Search bar, type the address in the Location bar.
Similar Messages
-
No matter what I try, only Yahoo and Bing search engines appear in the search box top right on Firefox. The Search engine manager only shows these two engines as well. I want to add Goggle and have not been able to. The default restore in the Search engine Manager is "Greyed out". What can I do to fix this ?
If those search engines are also missing in the searchplugins folder in the Firefox program folder (C:\Program Files\Mozilla Firefox\) then a (re)install should restore them.
If they are present then try to delete search.sqlite and search.json in the Firefox Profile Folder.
* http://kb.mozillazine.org/Profile_folder_-_Firefox
*http://kb.mozillazine.org/Unable_to_search_or_add_new_engines -
Query that only returns items that will produce a result
Thanks to Mack for his help yesterday. I would really appreciate some help from anyone who is more SQL competent than I am. I have an SQL problem that is just completely over my head. I've created a nifty tagging system for the blog, that sorts by tags and by multiple tags, check out the beta here: http://committedsardine.com/blog.cfm
When a user selects a tag, it adds it to the value list SESSION.blogTags. If the selected tag is there already, it removes it. When the list for tags pops up, I output all the tags, and show their state. You'll see what I mean if you try it.
What this leads to is the ability to select a group of tags for which there are no query results. What I want to do is only show those that will generate results and how many results they'll show. Like this, select "fluency" by itself there are 310 entries
fluency (310) | digital (234) | writing (12)
Once fluency is selected, there are 13 articles that ALSO are tagged by "digital", but none that are tagged by writing:
fluency | digital (12) | writing
I have a table called blogTagLinks, that is just for tying a tag to a blog. It lists a blogID and a tagID. Here is a sample of it for reference:
blogTagLinkID
blogID
tagID
4
2
2
5
2
3
6
2
5
39
1
18
49
1
1
42
1
9
44
1
19
47
5
14
48
1
22
54
16
22
I'm including all my sql, but the spot that I need help with is marked in red below:
<!---if URL.tg is defined, check to see if it exists in the database, then the SESSION, and either add or delete it from SESSION--->
<cfquery name="rsAllTags" datasource="">
SELECT tagsID, tagName
FROM tags
WHERE tagActive = 'y'
</cfquery>
<cfset allTags = ValueList(rsAllTags.tagsID)>
<cfif isDefined("URL.blogTags")>
<cfif ListFind(allTags, URL.blogTags) NEQ 0>
<cfif ListFind(SESSION.blogTags, URL.blogTags) NEQ 0>
<cfset SESSION.blogTags = ListDeleteAt(SESSION.blogTags, ListFind(SESSION.blogTags, URL.blogTags))>
<cfelse>
<cfset SESSION.blogTags = ListAppend(SESSION.blogTags, URL.blogTags)>
</cfif>
</cfif>
</cfif>
<!---get a list of all available tags, tags that if added to the already selected tags, will return a result--->
<cfquery name="rsAvailableTags" datasource="">
SELECT tagsID, tagName
FROM tags
WHERE tagActive = 'y'
NEED SOME STATEMENT HERE OF BLOGTAGLINKS TO DETERMINE WHAT TAGS WILL PRODUCE A RESULT
</cfquery>
<!---if searching by tags, get a list of the currently selected tags for display, the 0 returns an empty result if there are no tags--->
<cfif isDefined("SESSION.sb") AND SESSION.sb EQ "tg">
<cfquery name="rsTags" datasource="">
SELECT tags.tagName, tagsID
FROM tags
WHERE tagsID <cfif SESSION.blogTags NEQ "">IN(#SESSION.blogTags#)
<cfelse> = 0</cfif>
</cfquery>
<cfset variables.newrow = false>
</cfif>
<!---get the information for the blogs list, filtered by keyword or tag if requested--->
<cfquery name="rsBlog" datasource="">
SELECT blog.blogID,
blog.storyID,
blog.blogDate,
blogStories.storyID,
blogStories.blogTitle,
SUBSTRING(blogStories.blogBody,1,200) AS blogBody,
images.imageName
FROM blog, blogStories, images
WHERE blog.storyID = blogStories.storyID AND images.imageID = blog.photoID AND blog.blogDate < "#todayDate#" AND blog.deleted = 'n'
<cfif SESSION.sb EQ "kw">AND CONCAT(blogStories.blogBody, blogStories.blogTitle) LIKE '%#SESSION.blogKeywords#%'</cfif>
<cfif SESSION.sb EQ "tg" AND SESSION.blogTags NEQ "">
AND blog.blogID IN (
SELECT blogID
FROM blogTagLink
<cfif SESSION.blogTags NEQ "">
WHERE tagID IN(<cfqueryparam cfsqltype="cf_sql_integer" value="#SESSION.blogTags#" list="true">)
GROUP BY blogID
HAVING count(tagID) = #ListLen( SESSION.blogTags )#)
</cfif>
</cfif>
ORDER BY blog.blogDate DESC
</cfquery>There might be a single query solution but here's a query that you
will need to run for each tag in the database (cfloop over all the
tags) and will give you the number of blogs that have the selected
tags + the current tag
SELECT Count(*) AS blog_count
FROM (
SELECT blogID
FROM blogTagLink
WHERE tagID IN(<cfqueryparam cfsqltype="cf_sql_integer"
value="#SESSION.blogTags#" list="true">)
OR tagID = #currentTagID#
GROUP BY blogID
HAVING count(tagID) = #ListLen( SESSION.blogTags )#
OR count(tagID) = #ListLen( SESSION.blogTags )# + 1
) AS blogs
Mack -
Building a page that only shows up once for the same user...
I've been asked to create a page that only shows up once for a user. This page is to include a form that the user fills out, but once the user has filled it out, they wouldn't see the page pop up ever again. Does anyone know the best way to do this?
I was told to build an ip logger that checks the database for ip addresses and only shows the page if the ip address is unique. That might be way beyond my ability. Is there a program out there that I could possibly use?
My client wants this done asap, so any help would be much appreciated...
Thanks in advance!
JulesSome limitations of cookies are that user needs to enable cookies, cookies expire, cookies can be deleted by the client, and they're dependent on the machine/browser that the cookie was set to. Basically, by using cookies, you as a developer do not have any control over the presentation of the data for the visitor because the visitor can manipulate how the data is presented.
That means if more than one person shares the same browser on the same computer then after user 1 visits the page and sets the cookie then users 2,3,4 or whatever will not see the landing page that was intended for a first time visitor since user 1 already set the cookie. Once cookie expires the script will not see a valid cookie so the landing page will display once again. If cookies are disabled on the browser then a cookie will never be set and the landing page will always display. If cookies are enabled on the browser and cookie is set by a user then later the user deletes the cookie from their browser then the landing page will display.
Cookies can be set and checked using javascript or server side scripting. There's plenty of information on the limitations of cookies and how to set and check for set cookies if you search online for php cookies, javascript cookies, etc. or visit http://www.w3schools.com/PHP/php_cookies.asp
Control of your data from a database is the best method of development. If you do not have a registration system currently developed and it's imperative for each individual user to complete the form before continuing on to the site, then the form you speak of *IS* the registration form and should be developed with a database. What information does the user have to complete on this form?
Sometimes there are situations where you do not want to force a signup/login for the user to access a page, yet you still want to control data to some extent. In these scenarios the use of cookies is the only reasonable alternative, which is arguably better than using an IP method. It really all depends on the circumstances that are being considered. Personally I don't think this situation is well suited for cookies or IP use. Based off the information provided I believe this should be developed using a database and server side scripting. It also depends on the importance of the page that is being displayed after the landing page and the importance of the data retrieved from the submitted form on the landing page. If it's of low importance then go with a compromised method such as cookies or IP. If the data is important then use a database.
best,
Shocker -
Filter "Other users" to only show schems that have objects
I searched thru the forum, but didn't see this request anywhere. It would be nice to have a preference to only display "Other Users" who actually own objects in their schema.
In TOAD, there's a preference like this under Schema Browser->Data. Their preferences are:
* Show all users
* Only show users that own objects
* Only show users that own objects excluding Synonyms
* Only show users that own objects excluding Synonyms and Temporary Tables
This would be really useful for me, as our database has a ton of users that have no objects. :-)
Thanks for a cool product that works on my Mac!
--LeifIt is great to have this feature, but at our site it is VERY slow - so much so that I thought that SQL Developer had hung.
I assume that when this option is selected, the query is doing something like select distinct owner from all_objects and when the option is not selected it is querying user_name from all_users?
It takes only about a second to display our list of appoximately 1800 users (unsorted at the moment :( ) and it took 95 seconds to filter that list to the 235 users that have visible objects (we have ~ 240000 records in all_objects).
On another point, selecting this option effectively removes an already saved filtered user if it doesn't have any available objects. This seems to include checking against schemas with availble objects when expanding the "Other Users" node, which now takes significantly longer than when this option is not set - taking 60 seconds to expand the node which is filtered to just eight schemas out of the 235 with available objects.
Going back to the Other Users Filter to switch off this option appears to simply hang SQL Developer for the ~ 90 seconds that it takes to query the list of schemas with available objects.
I don't know whether it is possible to do something about this sort of performance, but with the performance I am getting at the moment, I won't be using this functionality. -
I downloaded a book sample to iBook. I deleted it and then bought the full book and downloaded it. The search engine keeps only searching the sample, about 50 pages, and not the full book. How do I get the search engine to search the full book?
I am having this exact issue. I just downloaded a book and went to open it and got this exact problem.
I purchased he book through indigo/kobo edition and paid for it and immediately went to open it and am getting the same error
Error getting License. License Server Communication Problem only mine says Bad Device key after.
Not sure why someone has not answered this question yet...i am using windows 7 and this is how i always do it. Never had this problem before when purchasing a book.
i hope someone answers this soon. -
How do I delete objects that only show up in outline view?
I have hidden objects in a file that only show up in the outline view. It will not let me select them and it's making the file larger then it needs to be. Any ideas to be able to get rid of these unwanted objects? Thanks!
There is nothing that is locked and it's only one layer. The normal view shows the ad as I need it but when I switch it to outline view there is a completely different ad stuck behind it, it will not let me select any of it to delete it and its making my file size way larger then needed. I tried to make a new file and move the normal ad over but it takes the entire thing with it. There has to be a way to get rid of that ad that's found its way in there somehow.
-
Meta tags for search engines needed only to homepage mainly ?
meta tags for search engines needed only to homepage mainly
?.oO(123polis123)
>meta tags for search engines needed only to homepage
mainly ?
A title and maybe a meta description belong to every single
page. But
much more important is usable and properly structured
content.
Micha -
Default search engine will not show
after the update to 35.0 yesterday my search engines wil not show.
In the add search engines they show, but not on the search bar.
See images for example.
Is this a bug, or am I doing something wrong?hello imans314, the multiple engines should appear once you start typing in the searchbar. if you just hit enter after the search term it will go to your default engine...
-
Customizing Slideshows - how do I add an image in the text box that only shows up for a specific ima
Customizing Slideshows - how do I add an image in the text box that only shows up for a specific image and not in every text box?
Can you maybe provide a screen shot to further explain your question?
Julia -
Search in Finder only returns results for "This Mac"
I'm experiencing the following, annoying issue with searching for files in Finder:
When I type a search text in Finder's search field, it only returns results when I select "This Mac". It does not return a single search result when being in any subfolder.
To make this a bit more clear assume the following structure:
| -– A
| | -- B
| | -- sample.pdf
| | -- another-sample.pdf
|
| --- C
| | -- yet-another-sample.pdf
|
| -- sample.pdf
I use finder to navigate to folder B. I type "sample" into the search bar. No results are returned.
Next I switch to "This Mac" and all of the above .pdf files are – correctly – returned.
The same happens when I'm in any other subfolder. Search only returns results when I switch to "This Mac".
Notes:
I'm not talking about network drives. All folders are local and below "This Mac" in the file system hierarchy.
I have forced Spotlight to reindex via sudo mdutil -E.
It happens on multiple machines, Snow Leopard upgrades and Lion clean installs.
Any idea? This bug renders Lion almost useful for me.I had the same problem .... found this link
http://osxdaily.com/2007/02/15/spotlight-wont-work-fix-a-broken-spotlight-menu-w ith-these-troubleshooting-tips/
And solution 3 the simplest, no wait the wierdest,
Change the screen resoultion then revert!
worked for me ...... go figure. -
How can i get a refined internet search, only show words that are used in search request
Can i get a refined search. For example, show only the words that have been entered in the searchbar
Hi,
You can try putting the word or phrase inside double quotes (" "). I think this would work in most search engines.
[https://support.google.com/websearch/bin/answer.py?hl=en&answer=134479&topic=1221265&ctx=topic Google Search help]
[http://help.yahoo.com/kb/index?locale=en_US&page=content&y=PROD_SRCH&id=SLN2242 Yahoo Search help]
[https://duckduckgo.com/params.html DuckDuckGo help] -
Need some help with PHP search engine
I am working on a search engine for my site that searches for
terms in my Submissions database. On the results page, I want to
categorize the results into different sections, depending on the
submission type. For example, there would be sections for audio
results, image results, and video results.
Below is the code I am working with. I copied it from a
tutorial and modified it a bit to work with my site, so I don't
completely understand it. What I have here seems to work just fine,
but this only shows audio results. I want to make queries for other
submission types as well, but I don't know how. My methods keep
failing, so I am hoping to get some help here.I am working on a search engine for my site that searches for
terms in my Submissions database. On the results page, I want to
categorize the results into different sections, depending on the
submission type. For example, there would be sections for audio
results, image results, and video results.
Below is the code I am working with. I copied it from a
tutorial and modified it a bit to work with my site, so I don't
completely understand it. What I have here seems to work just fine,
but this only shows audio results. I want to make queries for other
submission types as well, but I don't know how. My methods keep
failing, so I am hoping to get some help here. -
Do search engines recognize text that is retrieved from a
MySQL database with PHP?> I think a robot (spider)
> can get to any page on your site if its on your sever?
Nonsense. If there's no link to it, then it can only be found
by a lucky
guess.
> But the CAPTCHA is no longer secure
If done right it is.
> How do the mail spam bots get in they have to login
first, right?
Impossible.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Baxter" <baxter(RemoveThe :-)@gtlakes.com> wrote in
message
news:[email protected]...
>I don't know? But the CAPTCHA is no longer secure, I
think a robot
>(spider)
> can get to any page on your site if its on your sever?
How do the mail
> spam
> bots get in they have to login first, right?
> Thanks for your info on this,
> Dave
> "Murray *ACE*" <[email protected]>
wrote in message
> news:[email protected]...
>> Such pages are secure. How would the spider login?
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do
so!)
>> ==================
>>
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
>>
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
>> ==================
>>
>>
>> "Baxter" <baxter(RemoveThe :-)@gtlakes.com>
wrote in message
>> news:[email protected]...
>> > Yes that's what I mean, If you have to login to
get to the page with
>> > the
>> > database info or there is no link to the page
they will not index it?
>> > Thanks
>> > I think that is what I was looking for.
>> > Dave
>> > "Murray *ACE*"
<[email protected]> wrote in message
>> > news:[email protected]...
>> >> If you can see it in your browser, they can
read it. But - they
>> >> cannot
>> >> enter information in forms or use logins
and passwords, if that's what
>> >> you
>> >> mean.
>> >>
>> >> --
>> >> Murray --- ICQ 71997575
>> >> Adobe Community Expert
>> >> (If you *MUST* email me, don't LAUGH when
you do so!)
>> >> ==================
>> >>
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
>> >>
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
>> >> ==================
>> >>
>> >>
>> >> "bregent"
<[email protected]> wrote in message
>> >> news:[email protected]...
>> >> > >Then they must have some way to
not index pages with sensitive data
> on
>> >> > >them
>> >> > >is that what your saying. I know
they can index the php, asp pages
> but
>> >> > >what
>> >> > >about the data that the page
produces?
>> >> >
>> >> > Not sure what you are asking about
sensitive data. They read pages
> the
>> >> > same
>> >> > way they are rendered to browsers and
follow the links on the pages.
>> > They
>> >> > don't
>> >> > know if the text is coming from a
database or is static. They don't
>> >> > care
>> >> > if the
>> >> > data is sensitive or not. Look at the
source view of a dynamic web
>> >> > page.
>> >> > That
>> >> > is what the SE sees.
>> >> >
>> >>
>> >
>> >
>>
>
> -
Spotlight only showing results of 1 partition
I skipped lion and went from Snow Leopard to Mountain Lion. I am using a 1tb External HD. If I type "screen shot" into spotlight, it only shows the files on 1 of the partitions (there are 4 partitions on the drive) The one thing I noticed is that if I open a file from one of the other partitions, after doing so, that file will now also show up in spotlight. So to sum it up, spotlight only shows files from 1 partition, and files from the other partitions I've opened since I updated to Mountain Lion
Any Ideas?Re-index SpotLight
go into disk utility, select your OS X hard drive, click "repair disk permission". wait until it's done.
after that, go into terminal and type copy & paste:
sudo mdutil -E /
after that, terminal will prompt you for your password. type it in (no letters will actually appear but just type your password and press enter).
your spotlight index should then be recreated.
Maybe you are looking for
-
Is it safe to take my iPad Air through the airport scanners
IIs it safe to take my iPad Air through the airport scanners
-
Inserting a record in an Oracle database
Hi, I would appreciate if anyone could provide a code snippet showing how to insert a record into an Oracle 9i database. The columns in the database table have datatypes such as NUMBR, VACHAR2, and DATE. Some of the columns may be null. The input tex
-
Hi all, i want to know the logic maintained in abap program " RSNAST00" to trigger neu type output message and schedule details for that program triggered by batch job . Edited by: tech_bug on Apr 29, 2011 8:36 AM Edited by: tech_bug on May 5, 2011 1
-
How to invoke method dynamically?
hai forum, Plz let me know how do we invoke a dynamically choosen method method[ i ] of a class file by passing parameter array, para[ ].The structure of my code is shown below.. How will i write a code to invoke the selected method method?Plz help.
-
FBL3N screen layout is in disable
Dear Experts , Can you tell me in TC FBL3N , screen layout ikon shows disable , how i can make enable tell how this screen layout settings locked and unlocked for newly create screen layout Thanks Bhaskar