473,806 Members | 2,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?articl e=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 1603
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?articl e=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 databasedesigne r/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********@gma il.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?articl e=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.t ype_name = 'hot_news'
and articles.type = article_types.t ype

--
Henrik Hansen
Dec 14 '05 #3
Henrik Hansen wrote:
"frizzle" <ph********@gma il.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?articl e=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.t ype_name = 'hot_news'
and articles.type = article_types.t ype

--
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_arti cle_over_here.h tml
becomes site.com/news.php?id=783 46
(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********@gma il.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?articl e=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($_G ET['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?articl e=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($_G ET['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?articl e=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($_G ET['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

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

Similar topics

2
5306
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 page. Trouble is after moving to an apache server with php on a windows platform the script no longer works. It worked fine on the unix platform. All it does now is just wipes the text file and does not write anyhing else to it, any help would be...
0
1483
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 and (ii) a body. 2) Show the last X posts (or, better yet, just the last X titles) on a home page. 3) Show all posts on a "news" page. 4) When a news article is posted, email the news article (with the title being the email subject and the news...
2
1852
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 and (ii) a body. 2) Show the last X posts (or, better yet, just the last X titles) on a home page. 3) Show all posts on a "news" page. 4) When a news article is posted, email the news article (with the title being the email subject and the news...
3
2222
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 modification in my program so that the program can act in a similar way how real news server, that is to spread the new posts to another news server. But I do not have much knowledge about the way how news server chooses another news server to send...
0
1672
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. May I explain you what I have done. My database and data in that look like this. //* Data Base -- phpMyAdmin SQL Dump -- version 2.6.2-pl1 -- http://www.phpmyadmin.net --
0
9598
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.