Wednesday, April 25, 2007

PHP: mysql_fetch_row vs mysql_fetch_object

This is probably another one that everybody and their brother knew except me. I've always used mysql_fetch_row() to parse thru SQL results in PHP, but recently discovered mysql_fetch_object().

With mysql_fetch_row, you get an array of the items in the row... meaning if you queried the database with 'SELECT id, name, date FROM table', and call $row = mysql_fetch_row($query), then $row[0] is the id, $row[1] is the name, and $row[2] is the date. Seems pretty easy, until i found mysql_fetch_object.

Using that command, those same array vals are now object vals, so you can reference $row->id, $row->name, and $row->date. A little more typing, a lot easier to read. I think I'll stick with it.

Friday, April 13, 2007

CSS min-height and IE6

Today (for the last month, but i just attacked it today) I was trying to get someone else's CSS design from a template to a fully database driven page. I had it working in Firefox and IE7, but I don't have IE6 on my machine so I hadn't really tested it much on that. I had heard there were problems, but wasn't worried about them until today. So today, I discovered a couple fun problems with IE6. One is that min-height doesn't work very well on things that aren't tables. (I thought the whole point, or a big point, of CSS was to get rid of tables.) So in order to make my min-heights work in IE6 without breaking anything else, I used a little trick i found at a blog by Dustin Diaz (which is appropriately ranked #1 on Google for 'min-height IE6' searches). Apparently this problem has been around a while, I've just been busy using Flash. Good deal for me, it's already fixed.

Add this to your classes that have min-height in them:
class {
min-height:500px;
height:auto !important;
height:500px;

}

Worked like a charm. For me and about 500 other people who commented about it on his blog.

Thursday, April 5, 2007

Gimme back my cursor

Here's something I read this morning that reminded me of something I hate. Normally when you open a web browser, by default, your cursor is in the address bar. But some sites steal your cursor and move it where they want it. For example, Yahoo! moves it to the search bar of their homepage. That makes it hard to type a new address into the address bar and move on when you don't want to be on Yahoo!'s page. I thought maybe I was the only person bothered by this, since there is no sign of it changing, but thankfully I'm not.