0

Basically i'm new to web design and I have the basics of html only. I am looking to add a feed(I think) onto my website that allows a user to input text and it is then displayed in a list above the person befores text. Am I aiming to high to early or is this relatively achievable?

Thanks in advance,

cdes1145

4
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by Borzoi
0

Ok I think I understand what your talking about, do you mean that as he types in a text input the things he just wrote are above the text area?

0

Yeah, then if somebody else posts a message after it, it is the moved down with new post being at the top.

Thanks for the reply.

0

Hi cdes1145,

There are a couple of ways you could do this. If you have a database, you could store each post as a seperate entry. You would then display the database (in whichever order you like) with a form below it to enable users to add a new post.

Alternatively, you could store the posts in a text file, and display the results the same way.

Whichever way you choose to do it, you will need to validate/sanitize the data to remove any malicious code before it is displayed or saved.


Hope this helps
Zagga

0

Do you want this to happen in real time like an instant messenger or more like a message board/forum?

0

Zagga, I am using mySQL as a database. Borzoi I would like to make in relatively the same way a message board or a forum does. But rather than topics or sub topics just one thread.

Thanks

1

In that case, it's very simple.

In your database, you need a table with 4 columns: id , post_user , post_text , post_time id should be an int , auto-increment and your primary key post_user is the username of the user that made the post. Should be a varchar(25) . (25 characters should be enough). post_text is the post. It should be a text so that line breaks can be used. post_time would be the time of the post and what to sort by. Whenever inputting the time into the database, just use the now() function.

Make sure you use stripslashes() so that people can't use SQL injection.

When calling the data from the database, your query should look something like this:
(assume the table is called "Feed")

SELECT * FROM Feed ORDER BY post_time ASC

You would then go on to display the user, post, and post time in a table of some sort.

I used to have something like this on my site which I have since expanded upon to make it into a forum with topics and users.

Votes + Comments
Well written post, easy to follow with examples.
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.