?
Solved

Php Search Engines and Dynamic Content??!!

Posted on 2003-02-22
8
Medium Priority
?
235 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
[X]
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
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
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

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

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