I had created a dropdown list with fields lab,pharmacy and food.When

1.I select the lab it has to send the mail for those islab checkbox is true.

2.when I select the pharmacy it has to send the mail for those ispharmacy checkbox is true and in the same way for food.

I have tried for islab but I could not add for rest of them. Please help me.


   $connectionresource = Mage::getSingleton('core/resource');
   $readconnection = $connectionresource->getConnection('core_read');  
     $allrecord = $readconnection->select()->from(array('serviceprovider'=>'mg_serviceprovider'))->where('serviceprovider.islab=?', '1' 
       $alldata =$readconnection->fetchAll($allrecord);
     foreach($alldata as $data)

     function sendMailserviceAction($email,$pname){


<p><h2>Requisition Details:</h2> </p>
<p>Bloodgroup: '.$bloodgroup.'</p>
 <p>Units Required:'.$unitsrequired.'</p>
 <p>Required By:'. $requireddate.'</p>
 <p>City: '.$rcity.'</p>

 <p><h2>Seeker Details:</h2></p>

 <p>Name: '.$name.'</p>
 <p>Email : '.$cemail.'</p>
 <p>Mobile Number: '.$mobile.'</p>
 <p>City: '.$city.'</p>


 $mail = Mage::getModel('core/email');
 $mail->setSubject('Blood Donor');
$mail->setType('html');// YOu can use Html or text as Mail format

   try {
  //Mage::getSingleton('core/session')->addSuccess('Your Order is successfully Completed');
//return '<h2>Your Order has been submitted. Thank you for using labwise.   </h2>';
 catch (Exception $e) {
  //Mage::getSingleton('core/session')->addError('Unable to send.');
 // return '</h2>Unable to submit.</h2>'; 
 echo sendMailserviceAction();

  • this is database column name islab? Nov 18 '15 at 4:37
  • yes islab is column name in mg_serviceprovider table
    – Mouni
    Nov 18 '15 at 4:47
  • what are value for islab in database? Nov 18 '15 at 4:47
  • islab is checkbox
    – Mouni
    Nov 18 '15 at 4:49
  • checkbox have value what are the value of it check the database? Nov 18 '15 at 4:51

use this query for or condition..

 $connectionresource = Mage::getSingleton('core/resource');
       $readconnection = $connectionresource->getConnection('core_read');  
       $query="SELECT *
      FROM mg_serviceprovider  where islab='1' or ispharmacy='1'";
  $alldata =$readconnection->fetchAll($query);

         foreach($alldata as $data)
  • if islab=1 and ispharmacy=0 it has to send the email for islab provider.Does it works for this condition also.
    – Mouni
    Nov 18 '15 at 5:14
  • yes is it using the or condition 1 condition is true it will work Nov 18 '15 at 5:16
  • Ok.When I select the pharmacy from dropdown list it shows an another field upload button and I need to send the attached file to these providers also.How can I send these attachement
    – Mouni
    Nov 18 '15 at 5:17
  • ask another question for that with the form that have file name of file. i will answer briefly. Nov 18 '15 at 5:21
  • this code is working or not? and for attachment this will answer ur requirement magento.stackexchange.com/questions/9652/… Nov 18 '15 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.