OK, not too hard. The biggest problem I may have when coding it is properly inserting/reading the html in the database without screwing anything up. Also, make sure that the row, `id` is set to auto_increment 
PHP Code:
<?php
// Display gcode if ?id=# exists and only contains numbers...
if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
$id = preg_replace("[^0-9]","", $_GET['id']);
$result = mysql_query("SELECT gcode FROM table WHERE id='$id' LIMIT 1");
$result = mysql_fetch_assoc($result);
$old = array(""", "'");
$new = array('"', "'");
$gcode = str_replace($old, $new, $result['gcode']);
echo $gcode;
} else {
die("Error: Page number invalid. Please only use numbers (no letters, etc...");
}
?>
PHP Code:
<?php
// Insert HTML into database :D This is just the basics to make it work. You can add more to this if you have the desire to
if (!empty($_POST['gcode']) { // Just make sure that your field name is gcode ;)
$old = array('"', "'");
$new = array(""", "'");
$gcode = str_replace($old, $new, $_POST['gcode']);
$result = mysql_query("INSERT INTO table (gcode) VALUES('$gcode') LIMIT 1");
if ($result) {
echo "Created new page";
} else {
echo "There was an error creating your page.<br /><br />".mysql_error();
}
} else {
echo "
<form action='?submit' method='post'><div>
<textarea name='gcode'></textarea><br /><br />
<input type='submit' value='Create Page' name='submit' />
</div></form>
";
}
?>
PHP Code:
<?php
// Update HTML already in the database :)
if (isset($_POST['update']) && !empty($_GET['id'])) {
$id = preg_replace("[^0-9]","", $_GET['id']);
$old = array('"', "'");
$new = array(""", "'");
$gcode = str_replace($old, $new, $_POST['gcode']);
$result = mysql_query("UPDATE table SET gcode='$gcode' WHERE id='$id' LIMIT 1");
if ($result) {
echo "Page: $id updated successfully";
} else {
echo "There was a problem updating page: $id<br /><br />".mysql_error();
}
} elseif (!empty($_GET['id'])) {
$id = preg_replace("[^0-9]","", $_GET['id']);
$result = mysql_query("SELECT gcode FROM table WHERE id='$id' LIMIT 1");
$old = array(""", "'");
$new = array('"', "'");
$gcode = str_replace($old, $new, $result['gcode']);
$result = mysql_fetch_assoc($result);
echo "
Page <b>$id</b><br /><br />
<form action='?id=$id' method='post'><div>
<textarea name='gcode'>$gcode</textarea><br /><br />
<input type='submit' value='Update' name='update />
</div></form>
";
} else {
$result = mysql_query("SELECT id, gcode FROM table");
while ($result=mysql_fetch_assoc($result)) {
echo "<a href='?id=".$result['id']."'>Page ".$result['id']."</a><br />\n";
}
}
?>
If there's any errors, please let me know. To the best of my knowledge, there are no errors in this script, but I have not confirmed this.
-xP