Solved

Auto-mail function...

Posted on 2006-10-28
4
262 Views
Last Modified: 2012-05-05
Hello.
Seems that i need your Expert Opinion on this.
I want to create a function that will mail to users acording some results.
Let me explain a bit more what i want....
Im bulding a site where registered users can upload images and infos about each picture lets name it user_photos with many fields that holding infos about each picture.
I want to create a table, lets name it fav_user , where users will add some keywords in the fav_key field .
Lets say that the user1 add in fav_key the words...fish,shark,turtle...etc..
Later another user , user2, he is uploading 1 image with the word fish...
And another, user3, uploading some other images with the word shark...
I need a way to search in the user_photos table using the fav_key as keywords and later to mail in user1 that there are 2 new pictures in my site that contain the selected keywords fish and shark.
The problem is that ..
1)I want to send to user1 only 1 e-mail with the 2 results iv found and NOT 2 mails(one for each result)..and
2) if a 3rd user upload later another picture that contain one of the users1 keywords to mail again  user1 that 1 NEW picture is ready for him .
So far i can understand right that means that somehow i must keep log of the sended e-mails in order to Avoid to send the same infos to user1 more than once.

Can you pls tell me how must be the structure of my tables in my database?
And a general idea on how i can do what i want.

I hope that i explained well enough what i want to do.
Thnx in advance for your help...




0
Comment
Question by:NTGrE
  • 2
  • 2
4 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 17825161
hi

i would design the database like this :

pictures table - contains the picture code, the filename, userid who uploaded, and all the relevant details about the picture with the most important one - time of upload

keywords_per_picture table - contains one row for each keyword for each table
keywords_per_user table - contains one row for each keyword that a user entered
pictures_sent_to_user - contains one row for each picture code you sent to each user, and the time you sent it

now, what you need to do when you wish to send the email notification (let's say, once an hour)
1) get the max upload_time of pictures you sent to anyone (you can save it in a different control table so you will know to limit your search in the pictures table only to the new pictures you have not checked yet
2) for all the new pictures in the picture table :
  get all the users you need to send these pictures too (get the pictures keywords from the keywords_per_picture table   and join it to the keywords_per_user table.  order your result by userid
3) using a cursor create an email for each user (since you oredered the result by user id it will be easy to see which pictures should go to which user in a single mail)
4) update the picutres_sent_to_user table

sounds good ?

momi
0
 

Author Comment

by:NTGrE
ID: 17826122
Yes momi..sounds BILLIAND..cause you just giving me an idea !!!!
You r right about the time uploaded the picture..is the most important!!!
and you know why???
Since our script will run every hour we can do a search in items uploaded ONLY THE LAST HOUR...right??
This way i think that we avoid much work cause we dont need to monitor the sended e-mails and we ensure that the infos will send are unique.
Right???
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 17826166
yep
you are correct
since you are saving the update time you get this benefits :
1) scan only the last uploaded pictures since the last time you ran your program
2) send each picture only once to each user
3) it gives you flexability with timing your program (you can run it today once an hour, and next month, once every 30 minutes....)

i'm glad you like the idea

momi
0
 

Author Comment

by:NTGrE
ID: 17826285
Once again..Thnx momi..
I ll be back with more questions on this.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
get the data all row not only one row php 4 61
php image upload 3 45
count download link and run update query 9 70
setup wamp server for first time 2 70
Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question