Script advice.

Discussion in 'PHP' started by billybrag, Jul 27, 2006.

  1. #1
    Hello all,

    Im looking for some advice and suggestions.

    I have a job script and at present whenever a job is posted the job seekers who have opted in get an email.

    Obviously this means that if there are 10 jobs posted in one day then each user gets 10 emails. What I want to do is change this so that the user can choose 1 of 3 otions to have either daily weekly or monthly updates that would be sent on the morning of their chosen option.

    I have no idea the best way to go about designing this and wondered if anyone has done something similar and could offer some advice on how to do it?

    Im open to all suggestions.

    (im on a windows server if this means anything)

    Thanks

    Mike
     
    billybrag, Jul 27, 2006 IP
  2. almrshal

    almrshal Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    just include ur script here to be modified .. it's very simple code but relaying on ur main script , because of variables names ..


    regards

    Almrshal
     
    almrshal, Jul 27, 2006 IP
  3. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This is what I would do:
    - delete the code which send out email when a job is posted
    - make 3 cron jobs (daily, weekly and monthly) to replace the above
     
    rosytoes, Jul 27, 2006 IP
  4. [*-AnOnYmOuS-*]

    [*-AnOnYmOuS-*] Active Member

    Messages:
    253
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Totaly agree, although croning would be kinda hard job to corn tthis. If you could make a script that will let you do this by your own it would be better..
     
    [*-AnOnYmOuS-*], Jul 27, 2006 IP
  5. billybrag

    billybrag Peon

    Messages:
    324
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    how could i do this without a cron? is that even possible?
     
    billybrag, Jul 28, 2006 IP
  6. [*-AnOnYmOuS-*]

    [*-AnOnYmOuS-*] Active Member

    Messages:
    253
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #6
    [*-AnOnYmOuS-*], Jul 28, 2006 IP
  7. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #7
    In most webhosts, you can configure Crontab through a simple interface in CPanel.

    Thomas
     
    coderlinks, Jul 28, 2006 IP
  8. billybrag

    billybrag Peon

    Messages:
    324
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I fear you missed that from my first post :(
     
    billybrag, Jul 28, 2006 IP
  9. billybrag

    billybrag Peon

    Messages:
    324
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ok so I have come up with some Psuedo code in a kinda c++ style, can anyone help me convert it to php?

    thanks

    
    
    struct CategoryDesc
    {
    	String Monthly
    	String Weekly
    	String Daily
    };
    
    Map<String, CategoryDesc> CategoryStrings;
    
    
    /// first thing to do is populate the map with the correct strings
    
    // Get every job in the database < 30 days old
    for each job from the database
    {
    	if( job.age < 1 day )
    	{
    		/// get the item from the map so we can append a string might need to check it exists
    		CategoryStings<job.category>->Daily += "\n" . job.shortstring
    	}
    
    	if( job.age < 7 day )
    	{
    		/// get the item from the map so we can append a string might need to check it exists
    		CategoryStings<job.category>->Weekly += "\n" . job.shortstring
    	}
    
    	if( job.age < 30 day )
    	{
    		/// get the item from the map so we can append a string might need to check it exists
    		CategoryStings<job.category>->Monthly += "\n" . job.shortstring
    	}
    	
    	
    }
    
    
    // now that we have populated the map, we can search all users and email them
    for every user
    {
    	
    	String EmailString = "JIS email crap, job summary email intro crap"
    	switch( user.subscriptiontype )
    	{
    		case daily:
    			EmailString + = "JIS Daily email\n"
    		case weekly:
    			EmailString + = "JIS Weekly email\n"			
    		case monthly:
    			EmailString + = "JIS Monthly email\n"
    			
    		default :
    			// they are not subscribed
    			continue; /// skip this user, continue switches to the next for item...
    
    	}
    	
    	
    	for every category the user is subscribed too
    	{
    		EmailString += "Category : " . user.category . "\n====================\n";
    		switch( user.subscriptiontype )
    		{
    		case daily:
    			EmailString +=  CategoryStings<user.categorystring>->Daily
    		case weekly:
    			EmailString +=  CategoryStings<user.categorystring>->Weekly	
    		case monthly:
    			EmailString +=  CategoryStings<user.categorystring>->Monthly		
    		default :
    			// something is wrong if you get here
    		}
    		
    		/// close up the email
    		EmailSting += "please visit JIS for blah blah blah blah, thanks, the management.."
    		
    		SendEmail(to the user, with body "EmailString")
    		
    	}
    }
    
    Code (markup):
    It'll need to be associative arrays in php i think
     
    billybrag, Aug 1, 2006 IP