Php Search Engines and Dynamic Content??!!

Posted on 2003-02-22
Medium Priority
Last Modified: 2006-11-17
Hi there,
been looking at a few search engine examples for php driven websites and they look great but I am unsure about dynamic content. Part of my site will be dynamic, where the data is stored on mysql. What does one normanlly do in this situation. I would like to return hits from the pages that would be genereated from data on the DB that relates to the search.
Any help would be great
Question by:williery10
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 7998861
You just create your static pages like you always have done, and use links, forms, or whatever way you use to navigate, to call up PHP pages with dynamic contect when needed.  Of course, most of the stuff you see on must PHP pages is statis too.  That is the beauty of PHP, you create your page the way you like as if it were static, and you add <?php ...stuff... ?> in the page to add the dynamic parts.



<TITLE>Hit test</TITLE>
// database stuff to increment your hit counter...
// for purpose of example, also set the new hit count to the variable $hitCount
This is to show how to do this.  Also how to display a PHP variable inline.  The current Hit Count is <?=$hitCount?> and wasn't that cool!

Expert Comment

ID: 7999207
Simply store as much content as you can in the database and present all of it on the site in few simple page. You can end up serving virtually millions of pages with only one single PHP file.

The search is the same thing - you receive the search term and select from the database what is relevant to it. The database will return you only the records containing that string and you show the listing to the end user.

Something like that.

I think you should start from PHP Nuke (www.phpnuke.org) - it is the whole web potal for you. Just personalize it and start learning PHP that way :)

Maxim Maletsky
(yes, one of the many who created PHP for you)

Expert Comment

ID: 7999307
If you want to search through a MySQL database with a query word you can use a call like this:

$result = mysql_query("SELECT * FROM `table` WHERE title LIKE '%$keyword%' ORDER BY datecreated DESC ",$db);

You could also change it to get result from hits in multiple fields.
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users


Accepted Solution

ant2 earned 400 total points
ID: 8002625
You should store as much of the content in mysql, and crate a nice "search-engine" like this:
(If user adds more than one word in the search-field, all the documents that has ALL these words SOMEWHERE in a field, should be displayed)

$args = split(" ", $query);
for($i=0; $i<count($args); $i++)
        $cond .= "summary LIKE '%$args[$i]%'";
        $cond .= " AND summary LIKE '%$args[$i]%'";
$qid=db_query("SELECT id, title FROM content WHERE $cond");

What you could do with statis content is to add its plain text to the same table in the database as you have dynamic content, and give it a ID that is equal to the url to the static page.

Expert Comment

ID: 8010242
The better way is to use a spider search engine. It will index all of your files including dynamic files.

http://www.swish-e.org (very good)

Expert Comment

ID: 8010449
Oops...  I misread you question...  Most search engines won't accept query_strings in a URL so the best bet is to use URL rewriting to create a path into your dynamic content that does not rely on a query string.

So, you would use URL rewriting to make a page that is searched using somthing like this:
have a path that looks like this:

then you can submit your content to the search engines.  There are a couple of engines that will accept pages with a query_string, but as you might guess, the bigest and best do not.

Author Comment

ID: 8015470
Thats great guys,
all of your responses have given me a much better insight and understanding into this,

Author Comment

ID: 8015559
Thats great cheers

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question