email - php mail with while loop -


i need send job recommendation mail jobseekers skill week , timesjob template, 10 recommended jobs skill, write code below , can 10 jobs 10 emails not in same email , wrong code? can 1 me?

    <?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      */   //  , j.key_skills  '%".$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       users u,      job_seeker j,      category c,      degree d       c.category_id = j.functional_type  ,      d.degree_id=j.basic_qualification  ,      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 $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 * jobs `postdate` between date_sub( now( ) , interval 7 day ) , 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 * employer `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); } ?> 

the above example 1 tried

if you're getting 10 emails instead of 1, mail() function inside foreach() loop rather while() loop. change bottom of code this:

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

...to this:

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

also, has been mentioned in comment already, mysql_ functions deprecated , removed php codebase entirely. should switch mysqli or pdo interface queries, make sure code doesn't break in future php update.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -