Members of my site have a personal guestbook. I want to give them space for 100 comments. How can I achieve that if item 101 is posted, the oldest is being removed so that 100 items stay in the db ?
the mySQL table PersonalGuestbook:
pgID
pgName
pgComment
pgOwner
what i'd do is add an if condition saying that if total rows are > 100 then delete the earliest comment. this can be achieved by
$sql = mysql_query("SELECT * FROM PersonalGuestbook ORDER BY pgID ASC")
$id = mysql_fetch_array($sql);
$id = $id['pgID'];
$sqltwo = mysql_query("DELETE FROM PersonalGuestbook WHERE pgID='$id'")
and then just use the delete function to delete as many entries nessecary to revert back to 100 comments.
Bookmarks