Link to home
Start Free TrialLog in
Avatar of williery10
williery10

asked on

Php Search Engines and Dynamic Content??!!

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
Cheers
will
Avatar of Big_Red_Dog
Big_Red_Dog

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.


So:

foo.php:

<HTML>
<HEAD>
<TITLE>Hit test</TITLE>
</HEAD>
<BODY>
<?php
// 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!
</BODY>
</HTML>
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
maxim@php.net
(yes, one of the many who created PHP for you)
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.
ASKER CERTIFIED SOLUTION
Avatar of ant2
ant2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)
http://phpdig.toiletoine.net
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:
http://www.mysite.com/getregion.php?state=NJ
have a path that looks like this:
http://www.mysite.com/region/state/NJ

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.
Avatar of williery10

ASKER

Thats great guys,
all of your responses have given me a much better insight and understanding into this,
cheers
williery
Thats great cheers
Williery