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

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?

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.

Member Avatar for Zagga

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

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

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

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.

commented: Well written post, easy to follow with examples. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.