Reply to Re: News-Site kind of url

Your name:

Reply:


Posted by NC on 10/23/25 11:35

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

[Back to original 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

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