1

我需要在一周内按技能向求职者发送工作推荐邮件,它看起来像一个timejob模板,就像我的技能推荐的10个工作一样,我编写如下代码,但我可以通过10封电子邮件获得10个工作不在同一封电子邮件中,我的代码有什么问题?任何人都可以帮助我吗?

    <?php
    $today_date=date("Y-m-d");

/* jobs     
   key_skills
   id
   postdate
   reference_no
   company_id
   designation
   locations
   qualification
   industry
   job_type
   job_timing
   expr_min
   min_expmon
   expr_max
   max_expmon
   compensation_lacs
   compensation_thousand
   description
   cr_dt
   status
   interview_date
   intw_time
   intw_exptime
   t_status
   website    
 */
  //  AND j.key_skills  like '%".$get_singlekeyskill[$i_key]."%'


  "SELECT 
    j.id, 
    j.user_id, 
    j.first_name, 
    j.last_name, 
    j.mobile_no, 
    j.experience_years, 
    j.experience_months, 
    j.annual_salary_lacs, 
    j.annual_salary_thousan, 
    j.functional_type, 
    j.key_skills, 
    j.prefered_cityname, 
    j.basic_qualification, 
    j.post_qualification, 
    c.category_id, 
    c.category_name, 
    d.degree_id, 
    d.degree_name, 
    u.user_email 
FROM 
    users as u, 
    job_seeker as j, 
    category as c, 
    degree as d 
WHERE 
    c.category_id = j.functional_type 
AND 
    d.degree_id=j.basic_qualification 
AND 
    j.user_id=u.id"

$check_searching_query = mysql_query() or die (mysql_error()); 

$numtest_rows=mysql_num_rows($check_searching_query);     

    /* $fetch_allqry=mysql_fetch_array($check_searching_query);   */    

if($numtest_rows>0)
{ 
    while( $fetch_allqry=mysql_fetch_array($check_searching_query))
    {           
        $getjobseeker_id=$fetch_allqry['user_id'];      

        $get_usermailid=$fetch_allqry['user_email'];   



        $get_userfirstname=$fetch_allqry['first_name'];
        $get_usermobileno=$fetch_allqry['mobile_no'];
        $get_userexpyr=$fetch_allqry['experience_years'];
        $get_userexpmonth=$fetch_allqry['experience_months']; 
        $get_usersallac=$fetch_allqry['annual_salary_lacs'];
        $get_usersalthous=$fetch_allqry['annual_salary_thousan'];
        $get_userfuncttype=$fetch_allqry['category_name'];
        $get_userskill=$fetch_allqry['key_skills'];
        $get_userpreferedcityname=$fetch_allqry['prefered_cityname'];
        $get_userqual=$fetch_allqry['degree_name'];
        $get_singlekeyskill=explode(",",$get_userskill);    

        foreach($get_singlekeyskill as $get_userskill) {   

            /*
                job_seeker
                d
                user_id
                first_name
                last_name
                fathers_name
                dob
                gender
                marital_status
                country_id
                state_id
                city_name
                mobile_no
                tel_country_code
                tel_city_code
                phone_no
                experience_years
                experience_months
                annual_salary_lacs
                annual_salary_thousan
                functional_type
                industry_type
                key_skills
                resume_title
                prefered_city_id
                prefered_cityname
                basic_qualification
                post_qualification
                functional_type
                industry_type
                */

                /*
                category
                category_id
                category_name     
                */

                 /*
                    degree
                    degree_id
                    degree_name
                */

                  $sel_cron=mysql_query("SELECT * FROM jobs WHERE `postdate` BETWEEN DATE_SUB( NOW( ) , INTERVAL 7 DAY ) AND NOW( )  ") or die(mysql_error());  
                  $fet_cr=mysql_fetch_assoc($sel_cron) ;   

                  while($fet_cr=mysql_fetch_array($sel_cron))                     
                  {    
                    $db_job_id=$fet_cr['id'];     
                    $db_jpostdate=$fet_cr['postdate'];    
                    $num_empid=$fet_cr['company_id'];  
                    $sel_companname=mysql_query("select * from employer where `user_id`='$num_empid' ") or die(mysql_error());   
                    $fetch_companname=mysql_fetch_array($sel_companname);
                    $emp_companyname=$fetch_companname['company_name'];
                    $db_keyskill=$fet_cr['key_skills'];   
                    $db_minyear=$fet_cr['expr_min'];   
                    $db_minmon=$fet_cr['min_expmon'];   
                    $db_maxyear=$fet_cr['expr_max'];   
                    $db_maxmon=$fet_cr['max_expmon'];        
                    $db_locations=$fet_cr['locations'];             
                    $db_job_timing=$fet_cr['job_timing'];   
                    $db_designation=$fet_cr['designation'];   
                    $db_description=$fet_cr['description'];     
                    $db_interviewdate=$fet_cr['interview_date'];            
                    $db_complac=$fet_cr['compensation_lacs'];   
                    $db_compthousand=$fet_cr['compensation_thousand'];     

                    /*
                        $overall_arr[]=array($db_job_id,
                                    $db_jpostdate,
                                    $num_empid,
                                    $db_keyskill,
                                    $db_minyear,
                                    $db_minmon,
                                    $db_maxyear,
                                    $db_maxmon,
                                    $db_designation,
                                    $db_description,
                                    $db_interviewdate
                        );
                    */
                 }

                 $admin_emialid="renuka@osiztechnologies.com";

                 $content_pop="hfkhkdhfdjfjgdfjgdjgfjgdjfgjdgfj dvfdfhdgfhdgfsdgfhjdfh dhfgdhgfdjfg   " . $db_job_id;
                 $subj="Recoomended mail";

                 $headers1 = "From: JOBSITE \r\n";
                 $headers1 .= "Reply-To: ".$admin_emialid. "\r\n";
                 $headers1 .= "MIME-Version: 1.0\r\n";

                 $headers1 .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        }
    }
    mail($get_usermailid,$subj, $content_pop,$headers1);
}
?>

以上只是我尝试的一个示例

4

3 回答 3

2

如果您收到 10 封电子邮件而不是 1 封,那么您的 mail() 函数位于 foreach() 循环而不是 while() 循环内。从此更改代码的底部:

            $subj="Recoomended mail";
            $headers1 = "From: JOBSITE \r\n";
            $headers1 .= "Reply-To: ".$admin_emialid. "\r\n";
            $headers1 .= "MIME-Version: 1.0\r\n";
            $headers1 .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        }
    }
    mail($get_usermailid,$subj, $content_pop,$headers1);
}

...对此:

        }
        subj="Recommended mail";
        $headers1 = "From: JOBSITE \r\n";
        $headers1 .= "Reply-To: ".$admin_emialid. "\r\n";
        $headers1 .= "MIME-Version: 1.0\r\n";
        $headers1 .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        mail($get_usermailid,$subj, $content_pop,$headers1);
    }
}

此外,正如评论中已经提到的,mysql_ 函数已被弃用,最终将完全从 PHP 代码库中删除。您应该为查询切换到 mysqli 或 PDO 接口,以确保您的代码不会在未来的 PHP 更新中中断。

于 2013-03-01T15:03:16.857 回答
1

请使用内部联接或左联接,因为在执行此类操作时不会重复记录

于 2013-03-01T14:58:12.573 回答
0

您没有在作业表查询中提及任何 where 子句:

 $sel_cron=mysql_query("SELECT * FROM jobs WHERE `postdate` BETWEEN DATE_SUB( NOW( ) , INTERVAL 7 DAY ) AND NOW( )  ") or die(mysql_error()); 

我认为应该根据工作技能需要某种类型的where子句

于 2013-03-01T15:00:55.203 回答