ipwnzphp Posted July 25, 2008 Share Posted July 25, 2008 i have a mail() function inside a while loop of mysql and i need to make it only send the email 1 time for all the results like if joomla and web design is found only send 1 email for both. Quote Link to comment Share on other sites More sharing options...
ratcateme Posted July 25, 2008 Share Posted July 25, 2008 can you post some code? Scott. Quote Link to comment Share on other sites More sharing options...
ipwnzphp Posted July 25, 2008 Author Share Posted July 25, 2008 $keyword = mysql_query("SELECT * FROM `sl_keywords` WHERE c_id = '$id'"); while ($keywords = mysql_fetch_array($keyword)) { $key = $keywords['keyword']; $find = strpos($Desc, $key); if ($find == true) { $service = mysql_query("SELECT * FROM sl_services WHERE service = '$key' && c_id = '$id'"); $num = mysql_num_rows($service); $services = mysql_fetch_array($service); $service = $services['service']; $price = $services['price']; $hours = $services['hours']; $option = $services['option']; $Name = "$_POST[name]"; $Email = "$_POST[email]"; $Phone = "$_POST[phone]"; $Budget = "$_POST[budget]"; $Site = "$_POST[site]"; $Work = "$_POST[work]"; $Desc = "$_POST[desc]"; $Im_client = "$_POST[im_client]"; $message = "$company Free Quote System Form" . "\n\n"; $message .= 'Name: ' . $Name . "\n"; $message .= 'Email: ' . $Email . "\n"; $message .= 'Phone: ' . $Phone . "\n"; $message .= 'Project Budget: ' . $Budget . "\n"; $message .= 'Current Site: ' . $Site . "\n"; $message .= 'Type Of Work: ' . $Work . "\n"; $message .= 'Project Desc: ' . $Desc . "\n"; $message .= 'IM Client: ' . $Im_client . "\n\n"; if ($num) { mail($email, "$company - New Quote Request", $message, "From: $Name"); } } } Quote Link to comment Share on other sites More sharing options...
ratcateme Posted July 25, 2008 Share Posted July 25, 2008 why do you need the loop could you explain the loop more Scott. Quote Link to comment Share on other sites More sharing options...
ipwnzphp Posted July 25, 2008 Author Share Posted July 25, 2008 so it will pull the key words to match up with the services then it sends a email to the user. Quote Link to comment Share on other sites More sharing options...
ratcateme Posted July 25, 2008 Share Posted July 25, 2008 i think i understand now change if ($num) { mail($email, "$company - New Quote Request", $message, "From: $Name"); break; } that should stop the while loop and so it can only send one email Scott. Quote Link to comment Share on other sites More sharing options...
ipwnzphp Posted July 25, 2008 Author Share Posted July 25, 2008 thanks works great! i had tried continue; but it didnt work but break; did! Thanks again! Quote Link to comment Share on other sites More sharing options...
ipwnzphp Posted July 25, 2008 Author Share Posted July 25, 2008 o but wait.. if i have 2 services in the db it dont show both the services in the email it only shows 1 Quote Link to comment Share on other sites More sharing options...
ipwnzphp Posted July 26, 2008 Author Share Posted July 26, 2008 any help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.