The Misadventures of Dan

Peer into the mind of Dan as he tries to build an MP3 Player for his PDA and searches for the next thing in his life be it an electrical engineering job or graduate school.

Saturday, February 28, 2004

.:12:36:14 AM:.

.CBR Files and stuff

It's hard to keep track there are so many things on the net these days but recently my bro asked me what a .cbr file was. ".CBR" hmm... never heard of that before. A quick search revealed that it could some bitrate thing or comic thing. The latter made more sense due to the nature of the file but the page listed was dead. Fortunately, Google's cache feature saved the day :) Essentially for every page Google visits it makes a copy of that page (for faster retrieval of search words and stuff) and puts it in a place called its cache. This cache usually contains the text and links but no pics (which doesn't really matter). Going to the cache I found a link to 'CDisplay Comic Reader' which opens and sort of does a slideshow for image files. A CBR is a packaged (and compressed) set of images which are meant to be viewed sequentially which makes it good for the archiving of comic books and any sequential graphic stuff.


Tuesday, February 24, 2004

.:9:22:55 PM:.

Converting Tables to Reports...

In building the recent site, there's a page showing the movie listings. Originally (being the engineer) I kind of just lept through it by displaying it in a table format:

Date 1Place 1Show 1
Date 1Place 1Show 2
Date 1Place 2Show 3
Date 2Place 1Show 4
Date 2Place 3Show 5

To me, this looked pretty functional but definitely not pretty. I mean you could see all the information but there was a lot of repetition (i.e. the same date or the same place but different shows, etc. How on earth could I make it better?

Access gives you this awesome feature of being able to generate reports based on a table of information. You can group your information so it would sort of look indented like this:

In other words a nested list (check the HTML). The problem was... how on earth do you create a nested list!? I mean you can set up an SQL statement for each one but that to mean seemed like the wrong approach because it's too many queries. Rather, the better way to do it would be to do ONE query and then have PHP parse through the results ONCE (this is important because you don't want to tie up too much processing time).

The solution, once a friend helped me realize it, was pretty straight forward. Basically you need to approach it by looking at the previous line. If the previous line only changed by one field then you only add a new item to a list. If it changed by two, then you need to close the current list tag and start a new list item... and so on. I'll try posting the php code here:

//table2report.php
//Initialize current state pointers.
$currentday = "";
$currentplace ="";
while($row = mysql_fetch_array($results){
$nextday = $row["Date"];
$nextplace = $row["Place"];

if ( $nextday != $currentday){
//Close the previous list-always the third nested

//Display the new day
echo $row["Date"];

//Display the new place (this is a given because it's a new row... 
//there has to be a "new" place)
echo "\t" . $row["Place"];

}
elseif ( $nextplace != $currentplace){
//so we know that there's an old date but a new place...
echo "\t" . $row["Place"];

}
//now all that's left is to display the showtimes
echo "\t\t".$row["Time"];

} //Loop back and go for next row.


Sunday, February 22, 2004

.:2:54:09 AM:.

Version 1.0 is finally done.

May God be glorified. Please check out PassionatePrayer.com


home | archives