473,411 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

News-Site kind of url

Hi Group,

I'm builiding a sort of a news-site, with a mySQL backend.
Nowadays, i come across a lot of news-pages with the
title of the article in the URL. For example this one:
http://www.nieuwnieuws.nl/ (dutch in this case)

Anyway, every article seems to have it's own html-page.
I know that the page in my example actually has php-pages and
a mysql-db.

In my own site, i use htaccess to simulate directories and everything,
but 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?

Wouldn't it mean the queries would be extremely slow?

I hope my question is clear, since i don't exactly know how to explain.

Thanks, Frizzle.

Dec 14 '05 #1
10 1499
frizzle wrote:
Hi Group,

I'm builiding a sort of a news-site, with a mySQL backend.
Nowadays, i come across a lot of news-pages with the
title of the article in the URL. For example this one:
http://www.nieuwnieuws.nl/ (dutch in this case)

Geeft niks. Mooie taal.
Anyway, every article seems to have it's own html-page.
I know that the page in my example actually has php-pages and
a mysql-db.

In my own site, i use htaccess to simulate directories and everything,
but 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,
Probably yes.
Does this mean that the PHP looks in the DB "WHERE article =
'hot_news'" ?
Maybe. Hard to say.
Maybe the hot_news is something special, like a collection of articles.

Meaning it looks for a piece of text instead of an actual id?
I agree. A good databasedesigner/webappbuilder would avoid full text
substringsearch wherever possible.
But maybe the receiving script checks for special cases like 'hot_news' and
will respond accordingly.

For example: If it is an integer: get the article, if it is a special
string, do something else.


Wouldn't it mean the queries would be extremely slow?

I hope my question is clear, since i don't exactly know how to explain.

Thanks, Frizzle.


google for mod_rewrite
I expect such a module is behind it.

Regards,
Erwin Moller
Dec 14 '05 #2
"frizzle" <ph********@gmail.com> writes:
Hi Group,

I'm builiding a sort of a news-site, with a mySQL backend.
Nowadays, i come across a lot of news-pages with the
title of the article in the URL. For example this one:
http://www.nieuwnieuws.nl/ (dutch in this case)

Anyway, every article seems to have it's own html-page.
I know that the page in my example actually has php-pages and
a mysql-db.

In my own site, i use htaccess to simulate directories and everything,
but 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?

Wouldn't it mean the queries would be extremely slow?


could also be something like:

switch ($_GET["article"]) {
case "hot_news":
//do stuff
break;
}

if you see my point. I agree using text for the id is not the best
thing to to, but they could also be doing somekind of join with a
artucle type table like:

select *
from articles, article_types
where article_types.type_name = 'hot_news'
and articles.type = article_types.type

--
Henrik Hansen
Dec 14 '05 #3
Henrik Hansen wrote:
"frizzle" <ph********@gmail.com> writes:
Hi Group,

I'm builiding a sort of a news-site, with a mySQL backend.
Nowadays, i come across a lot of news-pages with the
title of the article in the URL. For example this one:
http://www.nieuwnieuws.nl/ (dutch in this case)

Anyway, every article seems to have it's own html-page.
I know that the page in my example actually has php-pages and
a mysql-db.

In my own site, i use htaccess to simulate directories and everything,
but 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?

Wouldn't it mean the queries would be extremely slow?


could also be something like:

switch ($_GET["article"]) {
case "hot_news":
//do stuff
break;
}

if you see my point. I agree using text for the id is not the best
thing to to, but they could also be doing somekind of join with a
artucle type table like:

select *
from articles, article_types
where article_types.type_name = 'hot_news'
and articles.type = article_types.type

--
Henrik Hansen


Thank you both for your answer!
Maybe 'hot_news' wasn't that good of a choice.
I meant that as a name of an article, not as a type
of news. So i guess the second explanation with swicth/case
isn't appropriate here? Or am i missing out on something?

And what it comes to the mod_rewrite part, AFAIK this works
with set up grids to which an URL should comply.
Like site.com/news/78346_cool_article_over_here.html
becomes site.com/news.php?id=78346
(if you get what i mean)

I still can't imagine there is a full-text search query related to
this.
(Even if the url would be saved in an extra field, and use
SELECT WHERE url = $_GET['url'] )

Thanks.

Dec 14 '05 #4
"frizzle" <ph********@gmail.com> writes:
Thank you both for your answer!
Maybe 'hot_news' wasn't that good of a choice.
I meant that as a name of an article, not as a type
of news. So i guess the second explanation with swicth/case
isn't appropriate here? Or am i missing out on something?


ah ok I get it, it's the title of the page.

I have seen solutions which simply write the whole page
structure on the server, as is, that's a fairly easy task too
and gives you nice urls. The only thing the pages would contain
was a page id (and a bit of handling code) which is used in the
sql tables.

--
Henrik Hansen
Dec 14 '05 #5
Hmm, i don't completely understand that.
You mean they actually create the files?

Greetings Frizzle.

Dec 14 '05 #6
NC
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

Dec 14 '05 #7

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.

Dec 14 '05 #8
I am not very familiar with Apache and htaccess options, but I think
some webservers can select a default (script) file by the directory,
even if more nonexisting subdirectories are given. You can then just
parse the REQUEST-URI to get the directory-style parameters.

Looking up a string is not that much trouble for a database. And there
are lots of possibilities to optimize it. The site could, for instance,
keep a relatively small table of "active" articles with name and ID. You
could look up the name in the small table quite fast, read the ID and
find the article by its ID from a much larger, more static, table.
On the other hand, special keywords like "latest news" could well be
filtered out in PHP and result in a query that requests articles sorted
by date.
It would not even be that hard to drive the entire article selection on
the news site by using just dates and categories. If your categories are
fixed, you could store them in some included PHP file instead of your
database if you really wanted to. But a categories table isn't that
large anyway, so there would be no need.

frizzle wrote:
Hi Group,

I'm builiding a sort of a news-site, with a mySQL backend.
Nowadays, i come across a lot of news-pages with the
title of the article in the URL. For example this one:
http://www.nieuwnieuws.nl/ (dutch in this case)

Anyway, every article seems to have it's own html-page.
I know that the page in my example actually has php-pages and
a mysql-db.

In my own site, i use htaccess to simulate directories and everything,
but 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?

Wouldn't it mean the queries would be extremely slow?

I hope my question is clear, since i don't exactly know how to explain.

Thanks, Frizzle.

Dec 15 '05 #9
NC
frizzle wrote:
NC wrote:

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.


how would you edit/update these?


You wouldn't. You would edit the articles stored in the database and
then re-publish (overwrite old static HTML files with new ones).
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...
}


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 ...


This is exactly what the above does. If $_GET['article'] is a number,
it is interpreted as an article ID, and the script shows full text of
the article. If it is not, it is interpreted as a topic identifier,
and the script displays only headers and/or opening paragraphs and
links to full text. Topic 'hot_news', in particular, includes five
most recent articles...

Cheers,
NC

Dec 15 '05 #10
NC wrote:
frizzle wrote:
NC wrote:

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.


how would you edit/update these?


You wouldn't. You would edit the articles stored in the database and
then re-publish (overwrite old static HTML files with new ones).
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...
}


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 ...


This is exactly what the above does. If $_GET['article'] is a number,
it is interpreted as an article ID, and the script shows full text of
the article. If it is not, it is interpreted as a topic identifier,
and the script displays only headers and/or opening paragraphs and
links to full text. Topic 'hot_news', in particular, includes five
most recent articles...

Cheers,
NC


Thanks for al the replies!
I think Dikkie Dik convinced me of how to do it.
But NC (not to be a nag) but topics on the page in my example,
www.nieuwnieuws.nl,
can be commented. Wouldn't there be a bigger risk in rewriting the
pages then
insert new comments in a DB?

Thanks! Frizzle.

Dec 15 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Cergon | last post by:
hi, i hope someone can help. Im pretty new to this php stuff and i have a slight problem. I have this script (shown below) which writes data to a text file which is then displayed on my front...
0
by: Jonathan M. Rose | last post by:
I am looking for a script that I can sit on an HTML server (Linux, Apache, PHP/Perl/Python/Etc.) that will allow me to do the following things: 1) Post news articles that consists of (i) a title...
2
by: Jonathan M. Rose | last post by:
I am looking for a script that I can sit on an HTML server (Linux, Apache, PHP/Perl/Python/Etc.) that will allow me to do the following things: 1) Post news articles that consists of (i) a title...
3
by: Lad | last post by:
I have a program that can send posts to a news server.The problem is that I must find a free usenet(news) server that allows posting, which is not easy. For this reason I would like to make a...
0
by: Gawn | last post by:
Dear all, Greeding from Thailand. Need help for my news script. I am trying to display news which keywords match the current page keywords. I am using Dreamweaver 8 and PhpMyAdmin to manage MySQL....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.