Category: Web Development

jquery load stylesheet into frame

For when I forget next time: <iframe name=”framename” id=”framename” src=”something.html”></iframe>$(‘body’,framename.document) .append(‘<link rel=”stylesheet” href=”” />’); or use this awesome jquery plugin: it allows you to easily run code and load css/javascript into iframes

Simple PHP MySQL Database Functions

A simple bit of code to make PHP database connections a little easier to use.<?phpfunction db_connect(){ $db = mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(“Cannot connect”); $dbcnx = mysql_select_db(DB_NAME) or die (“Cannot select db”); return $db;}function query($sql,$db){ $res = mysql_query($sql,$db) or die(“Error in sql $sql: “.mysql_error()); return $res;}function qa($sql,$db){ $res = query($sql,$db); $data = array(); while($row = mysql_fetch_assoc($res)){ if($res[‘id’])$data[$res[‘id’]] […]