rendered paste body <?php// If url is admin.php?edit=pastEntries... if ($_GET['edit'] == 'pastEntries'){ ?>// Display main page with list of entries, so long as url doesn't contain &id <strong>Past Entries: </strong> <?php// Query the database for the fields required $query0 = mysql_query("SELECT title, id FROM main ORDER BY date"); while(($oPast = mysql_fetch_assoc($query0)) !== false){ $id2 = $oPast['id']; $title = $oPast['title']; ?>// Display the entries <a href="admin.php?edit=pastEntries&id=<?=$id2?>"><?=$title?></a> <?php }// If the page has an ID, then it should be display the entry for that ID $id = (int)$_GET['id']; $oContent = $oBlog['content']; $oTitle = $oBlog['title']; $oDate = $oBlog['date']; $query1 = mysql_query("SELECT content, title, date, id FROM main WHERE id=$id"); while(($oBlog = mysql_fetch_assoc($query1)) !== false){ if(!$oContent){ $oContent = post_addslashes('content');} if(!$oTitle){ $oTitle = post_addslashes('title');} ?> <p>Posted date : <?=$oDate?></p> <form action="<?=$PHP_SELF?>" method="POST"> <textarea name="title" rows="1" cols="63"><?=$oTitle?></textarea><br /> <textarea name="content" rows="20" cols="63"><?=$oContent?></textarea><br /> <input type="submit" name="submit" value="Submit" /> </form> <?php if(isset($_POST['submit'])){ $query2 = "UPDATE main SET content = '$oContent', title = '$oTitle', date = '$oDate' WHERE id=$id"; mysql_query($query2); } } mysql_close(); } elseif ($_GET['edit'] == 'newEntry'){ ?> <strong>Add Entry:</strong> <?php $oContent = post_addslashes('content'); $oTitle = post_addslashes('title'); $oDate = date("F jS, Y"); $query = mysql_query("SELECT content, title, date, id FROM main LIMIT 0,1"); while(($oBlog = mysql_fetch_assoc($query)) !== false){ ?> <form action="<?=$PHP_SELF?>" method="post"> <p> <textarea name="title" rows="1" cols="63">Title</textarea><br /> <textarea name="content" rows="20" cols="63">Content</textarea><br /> <input type="submit" name="submit" value="Submit" /> </p> </form> <?php if(isset($_POST['submit'])){ $query2 = "INSERT INTO main (content, title, date) VALUES ('$oContent', '$oTitle', '$oDate')"; mysql_query($query2); } } mysql_close(); } ?>