How can I make the following code a widget for mu?
<ul>
<?php
$blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE domain!='mkcproductions.com' AND last_updated!='0000-00-00 00:00:00' ORDER BY last_updated DESC LIMIT 10");
foreach ($blogs as $blog) :
// we need _posts and _options tables for this to work
$blogOptionsTable = "wp_".$blog."_options";
$blogPostsTable = "wp_".$blog."_posts";
$opt = $wpdb->get_col("SELECT option_value FROM $blogOptionsTable WHERE option_name='siteurl'");
$opt2 = $wpdb->get_col("SELECT option_value FROM $blogOptionsTable WHERE option_name='blogname'");
// we fetch the title for the latest post
$opt3 = $wpdb->get_col("SELECT post_title FROM $blogPostsTable WHERE post_status = 'publish' ORDER BY id DESC LIMIT 0,1");
// we fetch the link for the latest post
$opt4 = $wpdb->get_col("SELECT guid FROM $blogPostsTable WHERE post_status = 'publish' ORDER BY id DESC LIMIT 0,1");
print "<li class="updated-blogs"><a href="$opt4[0]"><span class="updated-blogname">".ucfirst($opt2[0]).":</span> $opt3[0]</a></li>";
endforeach;
?>
</ul>
I'm a bit of noob at the widgets, so lot's of help might be required.