Alegro
Alegro

Reputation: 7956

Is it possible to write comments directly on page?

I found some php - jQuery code for creating commenting system.
So, comments are stored in a database, that must be read each time the page is loaded.

while($row = mysql_fetch_assoc($result))
{
    $comments[] = new Comment($row);
}

foreach($comments as $c){
    echo $c->markup();
}

Is it possible to write the comments not into database, but in a page directly, so they become the integrated part of the page ?

I can insert the comment using jQuery .insert() function and comments is there, but on refreshing, of course - it is lost.

Upvotes: 0

Views: 102

Answers (1)

Jason McCreary
Jason McCreary

Reputation: 72991

Is it possible to write the comments not into database, but in a page directly...

Yes. You could simply output using echo in PHP or with JavaScript. But as you already pointed out data will be lost on refresh.

You will need to use a persistent store - database, flat file, cache - if you want it to persist between refresh.

Depending on your use case, sessions or cookies are also options. Although not as persistent.

Be sure you understand the difference between client and server side technologies.

Upvotes: 3

Related Questions