Q:

PHP Repeating Divs - Comments

I am trying to create a comments section on a website to help people do their CV's and find employment.
How would i get the comments to create seperate divs, With newer comments appearing above the older comments. The code i have at the moment just replaces the content inside the comment output Div.
 Code is as follows:
HTML:
<body>
<div id="wrapper">
<h2><u>Interactive</u></h2>

                    Let us and others know your thoughts on this subject...
                    <br />
                    <h3>Thoughts:</h3>

                        <div id="form">
                            <form action="" method="post" >

                                <textarea name="Comments" rows="8" cols="40" value="" ></textarea>
                                <input type="submit" value="Submit" name="submit" onclick="location.href='test.php'" />
                            </form>
                        </div>
                <div id="Comments">

                    In this section, will be where your thoughts are displayed for others to see...

                <?php

                include "test.php";

                ?> 

                </div>
</div>
</body>

And PHP Code: 
<?php

echo "<div style=\"width: 400px; border: 1px solid black; padding: 3px; margin: 5px\">";

$comments = $_REQUEST ['Comments'];

echo $comments;

?>

Any help would be Appreciated...

A:

You need to loop through the comments and create a div for each comment. 
Something like the following: 
foreach ($comments as $comment) {
    echo "<div>".$comment['text']."</div>";
}

As far as ordering from newest, the comment posted is on point with reading about php and databases. Once you had a database and were storing comments there, another function that would be retrieving your comments would ideally return those comments in the order you want it in.
The best way forward for you, IMO, as a beginner, after you read a bit about php and databases, would be to choose a web framework, and use that to get started. I'm sure plenty of people out there would disagree with me, but there's too much you don't know at this point to competently put out a website built from scratch. But do learn the difference between the language and the framework. It's not all that clear in the beginning.  Just to fill in another blank, a framework often builds in such things as authentication, database access, and about 100 other core aspects of web applications that you will never build as well by yourself. Do learn about all of them though as it is hugely helpful to know what's happening behind the scenes as opposed to just accepting that it's done 'magically'. 

