Jump to content

Could someone help with my mailing list? Thank you in advance!


mrlol12

Recommended Posts

Hi guys,

 

I was just wondering if anyone could help me. I've got a My_SQL database containing articles, a summary for the article and a date. I have a basic CMS system set-up, but I want to create a script that when users sign up to a mail list it forwards the summary and dates of the articles database. If that makes sense? But I only want it to forward the most recent 5 rows. I'm pretty new to PHP and I've been mostly following tutorials thus far, but this is quite specific.

 

Thanks in advance!

Link to comment
Share on other sites

Hi

 

It's fairly straight-forward.

 

Run a MySQL SELECT statement to pull the data from the table and add

ORDER BY `date` DESC LIMIT 5.

 

This will effectively give you the 5 most recent database entries for you to attach / include in your emails

Link to comment
Share on other sites

Hi there,

 

Thanks for that. So in an e-mail I can ad the variable say...

 

$mailContent = "SELECT * FROM articles WHERE 'date' . 'title' . 'summary' ORDER BY 'id' DESC LIMIT 5"

 

Into the e-mail itself? And that would pull through the top 5? I only wanted certain column to pull through also, so would the way I have put it above work?

 

Also, how would I actually go about making an e-mail automatically send out per month?

 

Cheers!

Link to comment
Share on other sites

You'd need a lot more than that.

 

<?php
// create sql statement to get information from DB
$sql="SELECT columnName FROM articles ORDER BY date DESC LIMIT 5";

//run the query against the DB
$sql=mysql_query;

//set variable to count the items
$a=0;

//create array containing all data pulled from DB anc cycle through it to do what you want
while($row=mysql_fetch_array($sql){

//create array of 5 variables containing individual items
$mailContent['$a']=$row['columnName'];

//increment your counter
$a++;
}

 

Regarding mailing it out, I personally use Rmail.  Do a google for it, it'll save you loads of time.

Then all you do is create your mail it include items

(You can get them out of the array easily using a foreach loop)

 

Regarding sending periodic emails, you need to look into cron jobs and have a reference in your DB table as to when the last one was sent out.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.