2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by InsaneVr6
0

I assume that you have a generic 'story' page that displays the complete article. Your db table in this case will be something like (simplified):

id
user_id (poster)
title
summary (the bit that shows in the front page)
article (the complete story)

At the end of your summary, you'd have something like:

<a href="story.php?id=<?php echo $id;?>">read more...</a>

where $id would be taken from the 'id' field in the db table

However, you may find that the complete story is on another site, in which case you just need to store the url:

id
user_id (poster)
title
summary (the bit that shows in the front page)
article (the complete story)
url (external link)

You could add another field to note which field to use (article or url), but let use assume that if url is not null, then use this:

if url:

<a href="<?php echo $url;?>">read more...</a>

if article:

<a href="story.php?id=<?php echo $id;?>">read more...</a>

For the url scenario, you could add the 'target = "_blank"' attribute/value to open the external site in a new tab/window. Many frown upon this (and xhtml strict won't validate), but the choice is yours. I like links to new websites to open in new tabs, but that's just a personal preference and I'm probably in the minority by now.

0

Wow thanks alot.

My 'story' page is actually the index page, and the form is on the homepage as well.

My database is like this:

id
name (poster)
topic (name of post)
email (for contact purposes not displayed)
description (content of post)

I suppose that instead of description I should have summary and article.

Seems to make sense. My form has:

$sql="INSERT INTO posts (topic, name, email, description)
VALUES
('$topic','$name','$email','$description')";

How should I change this so that only a 'preview' shows up on the front page and then the rest is on the read more link? All of the article's will be stored on my site so no external links.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.