Thursday, June 16, 2011

SQL

Today I turned my sights on SQL, which is a database language. Information is stored in the database and can be retrieved with PHP, to be displayed in different ways.

My goal for the next few days will be a page that has 10 text boxes, for me to enter names in. After I submit, I want the names to appear in a list. I want to then have the option to sort them alphabetically, as inputted, or reverse alphabetically.

I could do this manually with jQuery, the last part anyway. I could write the list 3 times, each time in the correct order, then have jQuery hide 2 of them, and switch which 2 are hidden when I click. But I'd have to do it manually. PHP and SQL should be able to do it automatically.

I doubt this will be done today, I've got less than 4 hours until my shift is over. I'm not even sure I'll be able to get mySQL up and running on my webspace. But we shall see.

EDIT (5:51 pm):
Purdue offers students a mySQL account, which I've finally figured out how to access. From the web portal that is included, I've been able to create a new table and add data, as well as remove data and edit data. Next step, figuring out how to access the database from a webpage I create, and setting up the PHP calls. 2 more hours, what shall they bring us.

EDIT (7:48 pm):
I ended up switching gears to learn about HTML forms. Something I should have done a while ago, but hadn't. My first working experiment lets a user submit 5 names. It then writes the names to a txt file and lastly reads it back to the user. Demo, Text File (For confirmation).

Next I went after something more ambitious, a comment box. Users can enter a name and a comment, and then have it displayed back to them. The comment is recorded in a text document with that person's name, and the date and time of the comment. Try it out and let me know what you think, I'll be able to see any comments you leave.
 

No comments:

Post a Comment