Php code for auto deleting rows after one day

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Php code for auto deleting rows after one day

    hai friends this is my chat messages table

    PHP Code:

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

    CREATE TABLE IF NOT EXISTS `chat_messages` (
      `
    message_idint(11NOT NULL AUTO_INCREMENT,
      `
    message_user_idint(11NOT NULL,
      `
    message_to_user_idint(11) DEFAULT NULL,
      `
    message_messagetext NOT NULL,
      `
    message_room_idint(11NOT NULL,
      `
    message_timeint(11NOT NULL,
      
    PRIMARY KEY (`message_id`)
    ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=;

    --
    -- 
    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
    (110'testing .smile.'11418462529),
    (
    210're test .smile.'11418462902); 
    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

    PHP Code:
    $db->query("DELETE FROM chat_messages WHERE message_room_id = '$rid'"); 
    how to delete by time please tell me that thing thanks
    ComputerForumz - Latest Tech News


    Mobbest.tk-Free Mobile Downloads

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

    Comment

    Working...
    X