Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Php Search Engines and Dynamic Content??!!

Posted on 2003-02-22
8
Medium Priority
?
241 Views
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
Cheers
will
0
Comment
Question by:williery10
8 Comments
 
LVL 7

Expert Comment

by:Big_Red_Dog
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.


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>
0
 
LVL 1

Expert Comment

by:s-maxim
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
maxim@php.net
(yes, one of the many who created PHP for you)
0
 

Expert Comment

by:spencerslam
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
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++)
{
    if($i==0)
        $cond .= "summary LIKE '%$args[$i]%'";
    else
        $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.
0
 
LVL 8

Expert Comment

by:us111
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)
http://phpdig.toiletoine.net
0
 
LVL 7

Expert Comment

by:Big_Red_Dog
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:
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.
0
 

Author Comment

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

Author Comment

by:williery10
ID: 8015559
Thats great cheers
Williery
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

564 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