 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
12-14-2008, 02:32 AM
|
#1 (permalink)
|
|
The Acquainted
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
|
Newsletter
Hello everyone, I am trying to setup a mass mailer or in other words a news letter for my site. What is the best way to do this? Any suggestions?
|
|
|
|
12-14-2008, 03:11 AM
|
#2 (permalink)
|
|
The Contributor
Join Date: Mar 2008
Posts: 31
Thanks: 1
|
YOu have a database called e_lists
emailid, joindate, active can be your three attributes.
Then you hae a textbox + button in your php page. When people "signup" to your mailing list, you'll get their email and their joindate.
Then you can make a simple PHP script to loop through your records in your db table and email them.
|
|
|
|
12-14-2008, 01:34 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
@up- and an email field that contains the email, eh?
__________________
|
|
|
|
12-15-2008, 05:25 PM
|
#4 (permalink)
|
|
The Contributor
Join Date: Mar 2008
Posts: 31
Thanks: 1
|
Well your emailid can be your email field and a primary key.
|
|
|
|
12-15-2008, 06:33 PM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
No. Emailid should be the ID of the email. Which would be numeric.
It's both more logical, and opens up for other possibilities.
Not saying that it's critical in THIS example of use, but generally I would say that you should always have an ID-col in every table you have in your db.
__________________
|
|
|
|
12-15-2008, 06:40 PM
|
#6 (permalink)
|
|
The Contributor
Join Date: Mar 2008
Posts: 31
Thanks: 1
|
Its redundant espeically in this case.. I agree with you, a id column is needed but only when its required.
And you can figure out if you need an ID column by normalization.
I just want to point out that not every table requires an ID column. In this case an emailid (email address) field is a perfect example.
Most of my tables also use a GUID for a primary key where normalization would not lead to a two or more part primary key.
|
|
|
|
12-15-2008, 09:57 PM
|
#7 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
It is not redundant, not having a primary key keeps the door closed to a lot of things. Even for basic functions, the database works off of an indexed primary key much faster than a varchar value floating in a tables values.
Expansibility wise it is also a good idea. Primary keys make everything easy and fast to reference, you can also change anything else on the row without a problem.
Once again, its simply good practice to put a primary key in. Now it is not required, but being able to run does not make an application good.
|
|
|
|
12-15-2008, 11:21 PM
|
#8 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by Village Idiot
Even for basic functions, the database works off of an indexed primary key much faster than a varchar value floating in a tables values.
|
True, but there's no reason why that indexed primary key absolutely must be an auto-incrementing integer type.
For the particular situation of this topic, using an email address as the PK isn't a problem unless there are plans in the future to expand the system (but we can worry about that down the line, right? right?). The email address field (PK or not) will have to be indexed (unique) anyway to save repeated entries and keep the lookups speedy (e.g. when collating the addresses to send out).
All that said, there's good reason why using an integer auto-incrementing primary key is so common and it's a healthy habit to fall into.
|
|
|
|
12-15-2008, 11:24 PM
|
#9 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Let's say you want to advance this project later, to have permissions and access levels. So you have a usergroup, that user with emailid 'example@no-host.com' is a member of, lets him login on your site with his email and manage some things on list as an administrator.
Then he changes his email, woopsie, you have to manually change this cause there's noone with the emailid of 'example@no-host.com'.
Thus, an emailid as a numeric, and keeping the actual email in another field, is the better solution, as I said; It will open more doors for future use.
__________________
|
|
|
|
12-16-2008, 03:53 AM
|
#10 (permalink)
|
|
The Contributor
Join Date: Mar 2008
Posts: 31
Thanks: 1
|
Tanax I dont get that example, why would he have to do it manually? It could all be done automatically with minimal performance loss.
I can argue against that because now you have a numerical id, and therfore HAVE to make a join to the master table to make sense out of that numerical ID. And usually when I have to create a table which will reference another table then it usually done with GUID rather then int. I've found auto increment giving me a lot of problems before (espeically with duplicating, deleting etc etc)
Village Idiot, I didn't say not to have a primary key. And theres not really that much of a difference between an int and char primary key. In most cases it actually makes things easier.
|
|
|
|
12-16-2008, 11:28 AM
|
#11 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Because when you run a check to make someone an admin, you have:
PHP Code:
if($mysql['emailid'] == 'none@no-host.com') $_SESSION['admin'] = true;
When you change his email, he won't be an admin and you have to MANUALLY change the script. Instead of just having
PHP Code:
if($mysql['emailid'] == 3) $_SESSION['admin'] = true;
That way you can change his email without him losing his admin-status.
This isn't really a very good example, but it's just a small one to illustrate that you SHOULD have the id as a numeric.
And if you're getting alot of problems with auto increment, sorry for this, but that doesn't mean it's _wrong_. It could mean that you just need to practice more.
__________________
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|