Php code for auto deleting rows after one day

Started on the old forum in December 2014 · view the original in the archive · old links redirect here

1 reply · 108 views · started 11 years ago · 1 min read

2 participants
rajveer Developer · 104 posts #1

hai friends this is my chat messages table

--
-- Table structure for table `chat_messages`
--

CREATE TABLE IF NOT EXISTS `chat_messages` (
  `message_id` int(11) NOT NULL AUTO_INCREMENT,
  `message_user_id` int(11) NOT NULL,
  `message_to_user_id` int(11) DEFAULT NULL,
  `message_message` text NOT NULL,
  `message_room_id` int(11) NOT NULL,
  `message_time` int(11) NOT NULL,
  PRIMARY KEY (`message_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `chat_messages`
--

INSERT INTO `chat_messages` (`message_id`, `message_user_id`, `message_to_user_id`, `message_message`, `message_room_id`, `message_time`) VALUES
(1, 1, 0, 'testing .smile.', 1, 1418462529),
(2, 1, 0, 're test .smile.', 1, 1418462902);

can anybody provide me simple php mysqli code for deleting these two messages automaticly after 15 minutes i will tweak it later with my needs i know simple code of msqli of deleting everything

$db->query("DELETE FROM chat_messages WHERE message_room_id = '$rid'");

how to delete by time please tell me that thing thanks

something else Fellow · 2,296 posts #2

$db->query("DELETE FROM chat_messages WHERE message_time < '".time()-(60*15)."'");

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close