You are here: Re: News-Site kind of url « PHP Programming Language « IT news, forums, messages
Re: News-Site kind of url

Posted by frizzle on 12/15/05 01:49

NC wrote:
> frizzle wrote:
> >
> > what i wonder is how THIS system works.
> > If site.com/news/hot_news.html is converted to
> > site.com/news.php?article=hot_news,
> > Does this mean that the PHP looks in the DB "WHERE article =
> > 'hot_news'" ?
> > Meaning it looks for a piece of text instead of an actual id?
>
> First of all, it is entirely possible that HTML pages you are referring
> to are in fact static. Some content management systems actually
> separate writing, editing, and publication. An article can be
> submitted by the author and stored in a database until the editor
> approves its publication, at which point static HTML files are created
> and publication's home page and RSS feeds are updated.
>
> Now to your question. If you do decide to use mod_rewrite in the
> above-described fashion, you can simply do something like this:
>
> if (is_numeric($_GET['article'])) {
> $id = (int) $_GET['article'];
> $query = "SELECT * FROM articles WHERE id=$id";
> // Execute the query and display the article...
> }
> else {
> $search = $_GET['article'];
> switch $search {
> case 'hot_news':
> $query = "SELECT * FROM articles ORDER BY id DESC LIMIT 5";
> break;
> // more case statements here...
> }
> // Execute the query and display the article headers/teasers...
> }
>
> Cheers,
> NC

Thanks NC, but what i wonder in your first description of a system with
actual pages, how would you edit/update these?


And for your solution to my 'problem'; i meant how to handle DB-entries
if not reffered to them as ID's, but as actual topic names ...

Thanks. Frizzle.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация