Comment Demo

This is a demo to exercise MySql and PHP programming. It consists of 3 files:

I had intended this to be a demo of PHP and MySql programming. It still does that, but has changed a lot since it started. I originally used an example from a book, Learning PHP, MySql and JavaScript by Robin Nixon. And that's what it looked like, rather ugly with raw echo() statements returned from the comment_post.php file, and a link to take you back to this page. Once it "worked", I went off to do some other things  such as the Android app jata, and didn't return to it for a while. At some point, I decided to upgrade it, but the effort was interrupted and it was left in a broken state. I forgot it was broken and even sent out some links to the broken page in job inquiries.

I finally realized that and started to fix it. I realized I was not yet a very well rounded PHP, MySql, and Javascript programmer. I was comfortable with PHP, as it is similar to C. I knew enough about MySql to create tables, insert data, and run queries. Since then, I learned a lot more about SQL in general, using SQLite for Android programming. And I learned a bit about the value of javascript, jquery and Ajax.

Javascript was part of the original project, and it was only used to validate the form input fields. Later, I added some AJAX. Ajax is used to populate the comments section with a XMLHttpRequest sent to comment_post.php. This allowed me to add and use the "Sort by" radio buttons, and avoid re-loading the entire page just to display a new sort order. A javascript function doGetComments() reads a "Sort by" radio button with a call to document.getElementById("oldest").checked. A callback function request.onreadystatechange = function() {...} checks the return from the XMLHttpRequest GET request, and populates a <div> tag with the result.

Finally, I didn't like the flow of the page with the "add comment" form dangling in the middle or at the end.  So, I added some jQuery and jQuery UI, which are libraries of JavaScript functions.  The "Add Comment" button and the resultant floating comment form is created using jQuery UI. 

This project was developed using Eclipse, with PDT PHP Development Tools and RSE Remote System Explorer plugins. For test purposes, it is hosted on a server on my internal network. This is different from the method described in many "how to" articles which typically recommend a LAMP or WAMP server on the local Linux or Windows development machine.

Eclipse and Notepad++ are fine and dandy for editing and syntax highlighting of code, but for plain old html editing, I like a WYSIWYG editor, and I'm using Komposer for that.

Sort comments by: Oldest Newest    
The comments from the database should appear here.

All form fields are required.