csnyder chsnyder-at-gmail.com |nyphp dev/internal group use| wrote:
On Nov 21, 2007 6:43 AM, David Krings <[EMAIL PROTECTED]> wrote:
You want to use something else and not make it from scratch (unless you
insist).
If you _do_ insist, or you have some reason why third-party solutions
won't work, the simplest search accepts a single term and looks it up
using wildcards and the LIKE comparator:
$safe_q = mysql_real_escape_string( $_GET['q'] );
$query = "SELECT * FROM pages WHERE title LIKE '%{$safe_q}%' OR
content LIKE '%{$safe_q}%' ";
In many applications this pattern is sufficient for users to find what
they need.
It breaks down when searching hundreds of thousands of rows, or if you
need boolean searches (search for foo or bar) or some other sort of
advanced search functionality like stemming.
and if this is for your own project where you care more about satisfying
the user than meeting the specifications ;-)
run a commercial app like Atomz (very easy to set up) for a period of
time to learn your customer search behavior.
Of course it depends on your site, but for many sites there is a core
set of search terms that repeat over and over and over. Those represent
a core search need, of course, but also opportunity -- people are
looking for those things consistently. Use that information to improve
the internal navigation of your site, as appropriate. Also create a set
of core "info about this" pages for those terms, linked through from the
sitemap or table of contents or help page, to guide those searchers
exactly where you want them. Expose those "search term index" pages to
search engines as well, because they will be highly relevant for their
target terms and can bring you even more targeted visitors for those
terms. Note that Google specifically excluses "search results pages" via
their guidelines, but hand-crafted indexed pages as I describe are
perfectly "legal".
I remind myself at this point that "guide them where you want them" is
not always the same as "give them a direct path to where those words
appear on the site". Search sends them where the words appear. I send
them where the message of the web site is communicated most effectively
to those users searching for those terms. Like a good search engine
would ;-)
Atomz provides a customization feature that allows you to accomplish
this goal within their system 9and so does Google's site search
product). I have found the third-party dependence unnecessary for most
projects. For forums and highly-dynamic sites that need to be searched,
Atromz is great but gets pricey quickly as page views increase
(everybody needs to make a living). I have used Atomz since they
launched almost ten years ago... and I now know someone involved with
the project. Always quality, but as I said it is a busienss and there is
always a thrid-party dependency as businesses adapt to met their revenue
needs.
Hope that helps .
-=john
-------------------------------------------------------------
Your web server traffic log file is the most important source of web business
information available. Do you know where your logs are right now? Do you know
who else has access to your log files? When they were last archived? Where
those archives are? --John Andrews Competitive Webmaster and SEO Blogging at
http://www.johnon.com
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php