Game Quote Submission System

Well, it is done! I've tested it and it seems to be working without problem.

And here's how I did it:

I eventually came to the decision to use Movable Type's built-in comment system instead of taking the time to roll my own. I created what I'll call a shadow entry in the blog. Basically, it's an entry that will forever stay at Draft instead of moving to Publish.

After adding that to the database, I grabbed the entry_id out of the mt_entry table, and copied the Individual Archive Entry template into a new Index Template I called Submit Random Game Quote. I snipped out every template tag having to do with entries, and I was left with a title and an html form. I put the entry_id of the shadow entry into the form fields, and that was it. My submission page is complete.

And here is the code I used to pull out the Random Game Quotes:

$link = mysql_connect ("localhost", "username", "password");

mysql_select_db ("mt", $link);

$query = "SELECT comment_id
          FROM mt_comment
          WHERE comment_blog_id = 1
            AND comment_entry_id = 26";

$res = mysql_query ($query, $link) or die ("Invalid query: $query<br />". mysql_error ());

$total = 0;
while ($row = mysql_fetch_array ($res)) {
  $id[$total] = $row[0];
  $total++;
}

$quoteId = $id[rand (0, $total - 1)];

$query = "SELECT comment_text,  comment_author, comment_email
          FROM mt_comment
          WHERE comment_id = $quoteId";

$res = mysql_query ($query, $link) or die ("Invalid query: $query<br />".mysql_error ());
$row = mysql_fetch_array ($res);

$quote = str_replace ("\n", "<br />", $row[0]);

echo $quote."<br /><br />\n";
echo "<em>Submitted by:</em> <a href='mailto:".$row[2]."'>".$row[1]."</a><br />\n";

echo "<br />\n";
echo "<center><font size=-2><a href='/submitquote.php'>Submit a new Game Quote</a></font><br /></center>\n";

p.

2 TrackBacks

This was suggested as being relevant by a visitor. Read More

This was suggested as being relevant by a visitor. Read More

2 Comments

if you must run from two evils, death and women, run from the latter, they keep men in the grave.

if you must run from two evils, death and women, run from the latter, they keep men in the grave.

Leave a comment

About Me

I am a software developer for Six Apart living outside of Baltimore, MD. I have written a number of plugins for Movable Type, including the award winning MultiBlog, which has (as of MT 4) been integrated into the base application....
More...

Recent Entries

  • Minimalist plugins are fun!

    Last night I whipped up one of the smallest plugins I’ve ever written. It is so small in fact that I was able to stuff...

  • Feedburner Widget on MT News

    Movable Type News A WordPress 2.5 Upgrade Guide: And of course there are lots of third-party plugins for the MT dashboard, to integrate statistics and...

  • AD&D Monster Stats for the Presidential Canditates

    Charles Stross (scifi author, D&D nerd, and former perl columnist) posted Politics as she is Played with 3d6: The recent death of Gary Gygax, who...

  • Feedburner Widget 0.3

    At this point, I am really tempted to drop the ‘Widget’ from the name of the plugin, since it is doing so much more...

  • Feedburner Widget 0.2

    So I finally got around to updating the FeedburnerWidget plugin for MT 4.1 (since I finally got around to upgrading my install to MT 4.1)....

Close