Note that there are some explanatory texts on larger screens.

plurals
  1. POFetch and echo submitted text to individual li/div?
    text
    copied!<p>This is my first post here...</p> <p>I have a question regaring a news feed related function in html/php that I'm writing. You could say it's similar to "the Wall" which Facebook are using.</p> <p>So I have a input field on the top of the page, which posts the text the user has written and inserts to my database.</p> <p>The text later gets printed out on the page using echo.</p> <p>So far so good. I'm fetching things from the database, such as message, author, time etc. I've been able to show one message, with all the information shown in their right positions. The thing is; I want each submitted message to be echo'ed out in individual divs. I'm using an unordered list to create these individual containers in which each message will be shown.</p> <p>Now I'd like some assistance on the logic part. How should I do this?</p> <p>What I've been thinking about so far is posting a hidden ID with an increment on each submitted message. Then the website will check if there exist a message with an ID higher than the latest message shown on the website. If there is a message with a higher ID, then this particular message will be echoed out in another li. I'm not sure how these new li's will be created automatically though. Maybe I could echo the li out too, if there exist a value of ID higher than the latest displayed.</p> <p>Also I'm wonder about the fetch function. How can I specify what I want to fetch from a table and later echo this fetched data into a specified div?</p> <p>TLDR? What I'd like to happen.</p> <ol> <li>The user writes some text and submits.</li> <li>The text gets inserted to database.</li> <li>Fetch latest inserted text.</li> <li>Echo the fetched text into a new li.</li> </ol> <p>If there's anything I should clearify, please let me know. Thanks on advance.</p> <p>Edit; Let's say I have this big feed with a lot of posts, but I only want to show some of them. Let's say I have four users, two of them have the viewID 0 and the other two have the viewID 1. When a user with the ID 0 submits somthing, only the users with the ID 0 will see this message. How will this be achieved? I'm thinking that when the user posts a message a hidden viewID is posted too. After that SELECT from database where viewID = 0 etc. Maybe this could be done using cookies/session? I don't know if this is a huge step from what is written above?</p> <p>However. I kind of forgot that you can echo html, so my individual li/div's with the fetched texts could be done this way, fetching and echo:ing instantly on submit.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload