2013-03-01 2 views
1

일주일에 한 번씩 구직자에게 직업 추천 메일을 보내야합니다. 내 기술에 대해 10 가지 권장 작업처럼 timesjob 템플릿처럼 보이지만 아래 코드를 작성하지만 같은 이메일에없는 10 개의 이메일로 10 개의 작업을 얻을 수 있습니다. 내 코드에는 어떤 것이 있습니까? 어느 누구도 나에게 도움이 될 수 있니?while 루프가있는 PHP 메일

<?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="[email protected]"; 

       $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); 
} 
?> 

위의 단지 예를 하나 내가 친절이

+1

들여 쓰기가 모두 이상하고 일관성이 없기 때문에 코드를 읽기가 어렵습니다. 고칠 수 있니? – DiMono

+6

off topic : mysql_xx() 함수는 더 이상 사용되지 않습니다. 대체 mysqli 나 PDO 라이브러리로 바꾸는 것이 강력히 권장된다. – SDC

답변

2

1 대신 전자 메일이 10 개일 경우 mail() 함수는 while() 루프가 아닌 foreach() 루프 안에 있습니다. 이에서 코드의 바닥을 변경 :

  $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 코드베이스. 추후 PHP 업데이트에서 코드가 깨지지 않도록 쿼리를 위해 mysqli 나 PDO 인터페이스로 전환해야한다.

1

을 시도하다 작업 테이블 쿼리 : I 절 작업 능력에 따라 필요한 곳에 어떤 종류가 있어야한다고 생각

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

0

등의 작업을 수행 할 때에 언제 어디 절을 언급하지 않았다 기록이 중복되지 않기 때문에 조인 내부 사용에 가입하거나 왼쪽

관련 문제