Nested comments in PHP & MySQL
===

I searched through the forums but couldn't get an authoritative answer. I want to implement a nested comment structure in a way like this:

    <ul>
        <li>This is the parent first comment!
            <ul>
                <li>This is the reply for the first parent comment!
                    <ul>
                        <li>This is a reply for the first reply of the parent comment!</li>
                        <li>This is a third reply for the first parent comment!</li>
                    </ul>
                </li>
                <li>This is another reply for first parent comment!</li>
            </ul>
        </li>
        <li>This is gonna be parent second comment!
            <ul>
                <li>This is a reply for the second comment!</li>
            </ul>
        </li>
        <li>This is fourth parent comment!</li>
    </ul>

The dump for my table is below:

    +----+------------------------------------------------------------+--------+
    | id | text                                                       | parent |
    +----+------------------------------------------------------------+--------+
    |  1 | This is the parent first comment!                          |      0 |
    |  2 | This is gonna be parent second comment!                    |      0 |
    |  3 | This is the reply for the first parent comment!            |      1 |
    |  4 | This is another reply for first parent comment!            |      1 |
    |  5 | This is a reply for the first reply of the parent comment! |      3 |
    |  6 | This is a reply for the second comment!                    |      2 |
    |  7 | This is a third reply for the first parent comment!        |      3 |
    |  8 | This is fourth parent comment!                             |      0 |
    +----+------------------------------------------------------------+--------+

I know how to use `mysql_query()` and `while()` loops. A beginner in PHP & MySQL. Please help me out.