Skip to main content
April 16, 2007
Question

Title, Description & 1 | 2 | 3 Next

  • April 16, 2007
  • 2 replies
  • 420 views
Ok, let me explain my message title. I was wanting to know how to go about and create articles where they show a specific amount of text where the reader needs to select either page number or next to advance to the next page.

A perfect example would be the Jerusalem Post. Click here to go to the website and select any headline news. In there you will see that the article is lengthy however at the bottom of the article you can see that there is a next and previous and a page jump whether you want to go to any page.

I have already a database in MySQL that I have as...
articleID
title
desc

How do I replicate something like this website?
Is there a php function where lets say the desc table field counts the number of characters on a page? If so, what is this function called.

How do news websites create their articles as such.
This topic has been closed for replies.

2 replies

Inspiring
April 17, 2007
Something else I don't believe anyone covered what headlines to display
and in what order. For that you can expire date and an ordering field.
So your query will call for all records newer than a certain date
(greater than two days ago, for example) and then order them. You
could use the ID for ordering if it is an identity or some other method.

Just my thoughts.
Günter_Schenk
Inspiring
April 16, 2007
Hi,

first of all :: please don´t name your table field "desc", because this is a "reserved word" (desc = descending) -- please read more about which terms to avoid in table names here

>>
Is there a php function where lets say the desc table field counts the number of characters on a page?
>>

there are several ways to accomplish this using PHP functions which truncate a given string to a max. value of chars -- this is one possibility:

-----------
function article_preview($string, $max_length){
if (strlen($string) > $max_length) {
$string = substr($string,0,$max_length);
$string .= '...';
}
return $string;
}
------------------------------

this function can be reused like this:

<?php echo article_preview($row_article['description'], 40); ?>

to truncate the article to 40 chars, followed by "..."
April 16, 2007
Thank you so much for your help with the naming tip and code. I am new to the dynamic side of things especially PHP and all these timbits of information is most helpful. I tried your code and it works perfectly. The other question would be where the "..." is incorporated how do incorporate the id of the article lets say I have have a next and previous button, so they can click on next to read more of the article. I hope I am making sense.
April 16, 2007
>>
The other question would be where the "..." is incorporated
>>

well, I would use this "truncate text" method only on, say, the Jerusalem Post main page -- when you have a clickable headline and want to display an excerpt of the contents below. When looking at this page, I *think* they decided on a different solution, because the excerpts all have a different length :: they assumingly use an extra field like "description_preview" for defining the article´s summary manually -- much too often the "automatic truncation" won´t produce meaningful stuff ;-)

>>
lets say I have have a next and previous button, so they can click on next to read more of the article
>>

If I were you, I´d actually use two related tables :: one containing the articleID and the title, and another one for storing the "pages" which are related to a certain "articleID" in the first table. This method does have some advantages over your current attempt to store the article contents in the same table :: when storing the articles in a different table, you can assign an arbitrary number of them to, say, articleID 1 (those articles will also share the same title BTW) -- and that´s also a prerequisite for extensions like Tom Muck´s Recordset Navigation Suite, which provides a good variety of "paging" options.

your separate "articles" table should provide at least this structure:

- ID (numeric, primary, auto increment)
- articleID (numeric, for defining an article´s relation to the articleID in the first table)
- article_content (text)

You are right. Thank you that is most helpful. About Tom Muck´s Recordset Navigation Suite, I have been thinking about purchasing it but one thing has held me back and that is the same with the Interakt products is that now that Adobe has made Dreamweaver CS3 can these products be used? I do not know about whether to make a investment on the new Dreamweaver CS3 because of the products mentioned above. However, one thing I was thinking about and I do not know if anyone has tried this but can two seperate dreamweavers lets say CS3 and MX 2004 can be installed on the same computer and be used seperately if they are both the full version or upgrade?