Question:

PHP user id mail or message with replay sql table an autodelete

by  |  earlier

0 LIKES UnLike

I want to set up a website mailbox systme with php, i already have a crappy task setup but want to burn this and start a fresh one.

I am going to use SQL tables to set this up with a message and reply table from user id to user id, how do I make the message delete after the individuals mailbox has reached a certain number of messages, or mb's. can SQL delete a line in a table once it has reached a certain number?

Does anyone have any good ideas with how to set up a mail program PHP with the least amount of code possible

 Tags:

   Report

1 ANSWERS


  1. I do not think SQL has this feature in it. What I would do is run a bit of code that checks the number of messages and deletes any if required when the user loads their Inbox.

    example:

    <?php

    db_connect();

    $sql = "SELECT * FROM mail WHERE to = '$userid' ORDER BY date_sent";

    $result = mysql_query($sql);

    $count = mysql_num_rows($result);

    if($count > 50){

    //delete last row

    }

    ?>

    Replace the '50' in the if statement with whatever you want your limit to be and add in another SQL statement to delete the last row (or whatever you want to do).

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.