whi01135879 Posted October 28, 2010 Share Posted October 28, 2010 Hi everyone, im new to php, iv just created a news feed where i have a limit of 10 to be echoed out. but i want the update form to delete the oldest post as it updates... how would i do this please : Quote Link to comment Share on other sites More sharing options...
whi01135879 Posted October 28, 2010 Author Share Posted October 28, 2010 <?php if($_POST['submit']) { $title = trim(stripslashes($_POST['title'])); $news = stripslashes(nl2br($_POST['news'])); if($title&&$news){ require_once("../inc/connect_to_mysql.php"); $dateof = date("Y-m-d"); $insert = mysql_query("INSERT INTO newsfeed VALUES ('','$title','$news','$dateof')"); die ('<p class="accepted">Your news has been posted</p>'); } else{ $msg_to_user = '<p class="error">Please fill out the title and news update to procced.</p>'; } } ?> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted October 28, 2010 Share Posted October 28, 2010 <?php if($_POST['submit']) { $title = trim(stripslashes($_POST['title'])); $news = stripslashes(nl2br($_POST['news'])); if($title&&$news){ require_once("../inc/connect_to_mysql.php"); $dateof = date("Y-m-d H:i:s"); $insert = mysql_query("INSERT INTO newsfeed VALUES ('','$title','$news','$dateof')"); $delete = mysql_query("DELETE FROM newsfeed ORDER BY dateField DESC LIMIT 1"); die ('<p class="accepted">Your news has been posted</p>'); } else{ $msg_to_user = '<p class="error">Please fill out the title and news update to procced.</p>'; } } ?> Quote Link to comment Share on other sites More sharing options...
whi01135879 Posted October 28, 2010 Author Share Posted October 28, 2010 Sweet just changed that code now works ace :P <?php if($_POST['submit']) { $title = trim(stripslashes($_POST['title'])); $news = stripslashes(nl2br($_POST['news'])); if($title&&$news) { require_once("../inc/connect_to_mysql.php"); $dateof = date("Y-m-d"); $insert = mysql_query("INSERT INTO newsfeed VALUES ('','$title','$news','$dateof')"); $delete = mysql_query("DELETE FROM newsfeed ORDER BY ID LIMIT 1"); die ('<p class="accepted">Your news has been posted</p>'); } else{ $msg_to_user = '<p class="error">Please fill out the title and news update to procced.</p>'; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.