Using form_dropdown in codeigniter to populate from the database

in the controller send this:

   $data["fruits"] = $this->db->get('fruits')->result();

Now you could go and loop through each fruit and create a select form input tag and create options with a selected option like this:

    echo "<td><select id='". $fruitbasket->id ."'>";
    echo "<option value=''></option>";
    foreach($fruits $f){
        if($f->id == $fruitbasket->moldiest){
            $selected = " selected=selected ";
        } else {
            $selected = "";
        echo "<option $selected value=" . $f->id . ">" . $f->name . "</option>";
    echo "</select>";

or you could use the form_dropdown helper:

    $fruit_options = array();
    foreach($fruits as $fruit){
    echo "<td>" . form_dropdown('', $fruit_options, $fruitbasket->moldiestfruit,$fruitbasket->id) . "</td>";

The tiny bit of overhead is that codeigniter puts the result in an array of objects rather than an array of arrays which form_dropdown asks for, so the tiny loop is required to create the options variable.

Undergrad Heroes – Movie Idea

A group of Undergrads set up a society to create superhero costumes using their course subject matters, a chemistry student, a fashion student, an engineer, a law student and an aspiring comic book artist who is an art student; being the one who organised the society.

The superhero costumes are only intended to be used as final year projects until an evil gang start terrorizing the campus and the surrounding town.

Will they carry on designing the costumes for research purposes or will it become more practical?

Posted in Uncategorized

Compelling Reasons to start using Ruby on Rails now!

Ruby on Rails as a programming environment

  • Plugin support for external logins (i.e login via facebook)
  • Activemerchant (support for merchant gateway integration into native apps with less hacking) as used in
  • Great community (stay up to date with, railscasts etc)
  • Scaffolding
  • the basic actions have the code generate for them
  • Migrations; every database change is saved in the revision control, no more asking for sql files
  • Git pulls (the live websites can pull all the changes rather than using ftp to upload, and all changes are in git no matter what)
  • gems (for example acts_as_taggable_on)

ruby is really great, everything can be done on ruby and most often than not the techniques carry on evolving unlike php scripts and libraries that haven’t changed and need shoehorning into a modern application.

Using Rails as a platform to setup of the shelf systems

Spree, a shopping cart system written in rails

Radiant CMS

  • A CMS which has a templating system similar to ExpressionEngine but much less daunting.
  • The techie bits are separate to the wordy bits (client still has all the buttons, but they are hidden away but they know it’s still there)

Refinery CMS

  • The interface is very sleek and only the client interface is visible from the back end (content and navigation)
  • the power is in the command line, it looks simple but the it has more scope which goes past the simple CMS website.


  • This is for internal use and also installation for client sites.
  • Ticketing/task system with client logins and pop3 collection.
  • Milestones
  • Burndown (estimating time left as the project goes along, with nice charts)
  • Time Tracking
  • Invoicing
  • Communication (questions asked are not forgotten, conversations can be private)
  • It is very actively developed.

Others (nesta, typo, etc.)

Posted in Uncategorized

How the post office could save billions!

When a letter is sent to an address it is immeditately put into the delivery schedule for the day when it arrives at the local depot.

This means that post(people) deliver the post every day and to every address (i.e. you can recieve a letter on monday and a letter on tuesday)

The solution is to only deliver a postcard which is like a mail notification (the postcard will say; i.e. you have 10 letters)

This way when the post office is storing those letters for more than 3 months or so they would know to notify the sender that someone is not responding to the letters. This would reduce junk mail and also remove the need for multiple deliveries in the same week to the same address.

This is also the perfect solution for delivery of bulky items, on a majority of occasions items are sent to an address when noone is there to collect (they have jobs) instead of this the person expecting a package on the said day can just go directly to the post office to collect that item.

An addition to this solution is to combine train stations and post offices, the postal service will then be able to use the trains as part of their delivery network and further save on fuel costs; the main benefit is that the delivery staff that would have lost jobs by no longer daily delivering would use their resources to shuttle the mail from one post office to another.

This would be a definitive solution to solve the debt in the postal service.

Posted in Uncategorized