Posted by & filed under Intern Atonement.

I keep just posting these damn things on the weekends, maybe I’ll just make that my thing. Knowing how things work, I’ll start posting in the evenings after I’ve finished for the day. Just to contradict myself. I know me:

Feb. 9, 2010: So I spent the day writing a Codeigniter controller program for the database of glossary terms/definitions. I mainly just wrote and read about Codeigniter and the MVC framework. Here’s a brief explanation on what the hell MVC is: Codeigniter is a framework that separates the application logic from the presentation. This means that your webpages contain less code because the webpage itself is separate from a lot of the code that controls it. It’s broken up into three structures: the Model which is where all your functions are created that will work with your database. These include functions to insert, delete, update, and retrieve information. Another is the Controller which acts like a traffic controller. It takes the information from the model and directs it to the view. It’s where a lot of work gets set up in Codeigniter. The last is the View which is basically just a webpage, or a fragment like a header or footer. It’s what’s displayed to the user. This is the basics behind Codeigniter’s idea. Sort of a content management system for PHP.

Here’s a shot of the simple controller I built:

After I finished this, I decided to work on some PHP exercises out of my book that dealt with PHP and databases. I had a lot of trouble connecting to MySQL. For the rest of the day I was trying to troubleshoot and debug my programs. No success. At least, not on this day.

Feb. 11, 2010: Today was a tougher day than I was hoping for. I decided to just try and get the glossary page to print out the table before I tried concentrating on specific categories (i.e. the letter links). Apparently, my browser didn’t like that. A sample of code:

This is the HTML on the original page:

All coded into the HTML which makes for some long ass code.

Here’s the PHP for the new view. Greatly simplifies things:

I guess it doesn’t like the foreach code.

I struggled to find out what the problem was. I showed it to Stevie after a while and he said it looked great to him and he wasn’t sure what the problem was. He suggested making an even simpler function in the model. I did. It still wasn’t working. It became a pain in my ass for the rest of the day. I felt defeated.

Feb. 12, 2010: So, after going up to Evergreen and working with Cody on our other project and running a whole bunch of errands, I decided to mess around with the code I wrote for the exercises out of the book. They weren’t working, so I did some serious investigative work (this means I did some Googling) and I finally managed to find a forum where they discussed a similar problem to mine. As I was reading the examples, I noticed that some of the code was slightly different from mine (and the authors). An example: (mine) @mysqli_select_db[‘myblog’]. I changed it to: $dbc->select_db($dbname). $dbc is the variable that holds the username, password and hostname. $dbname is the variable for the database. I put these in after reading the forum post. It works (the exercises in the book, not the glossary page). I guess it was just deprecated syntax. This is a great book, but I think he needs to write an updated fourth edition. I feel a lot more confident.