Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Managing newsletter signup (php, mysql)

  • 18-01-2007 5:06pm
    #1
    Closed Accounts Posts: 8,866 ✭✭✭


    Hello all,

    I'm currently on to something new, newsletters. I've a site with member signup etc. and on the signup form i have a checkbox for whether or not the user would like to receive the newsletter. Obviously I then store the value in a database and select all from emails where newsletter = 1 blah blah blah

    The complication arises when I expand it to topics. So the user checks the box to receive the newsletter, but then there are 10 more checkboxes for different topics within the newsletter. How do I manage this?

    And I don't just mean database wise(though i'm not to sure on that, will i need a field for each checkbox), I mean how do I dynamically edit the content of each individual email based on each users topic preferences?

    Thanks in advance!


Comments

  • Registered Users, Registered Users 2 Posts: 4,099 ✭✭✭muckwarrior


    I guess you'd need to somehow split the newsletter up into different sections in accordance with topic and then pull in required sections when building the email that is to be sent to the user.

    How is the newsletter composed?


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Undecided on the composition yet, whatever method will best suit the requirements I suppose!


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Database-wise, create a new table called "topic". Within this table, you'll have a field topicID.

    Then you have another table, called "selectedtopic" or something. All this table will have is userID - topicID pairs, i.e.
    +---------+----------+
    | UserID  |  TopicID |
    +---------+----------+
    |         |          |
    |    1    |    2     |
    |    1    |    3     |
    |    1    |    4     |
    |    3    |    6     |
    |    3    |    1     |
    |    4    |    4     |
    |    5    |    6     |
    |    5    |    7     |
    |    6    |    1     |
    |         |          |
    +---------+----------+
    
    This is your list of what topics each user has checked.

    Then in your script, load in all the topics to an array, and run a query which locates all users, and which topics they've subscribed to, e.g.

    SELECT user.*, selectedtopic.topicID
    WHERE user.newsletter AND user.userID = selectedtopic.userID
    ORDER BY user.userID, selectedtopic.topicID

    Then you iterate through the resultset and for each user, build the newsletter containing the topics they've selected, and send it off, then move onto the next user.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    I suspected as much seamus, I was harbouring a small hope that there would be a less tedious method but I couldn't see any option beyond that! Ah well...

    Thanks though!


Advertisement