ninjamonky Posted September 30, 2009 Share Posted September 30, 2009 I have created this small script to email rows from mysql database. <?php include_once('include/database.php'); // Database connection details include_once('include/database.class.php'); // access database functions $db=new database(DBHOST,DBNAME,DBUSER,DBPASS); // database connection $sql=mysql_query("SELECT * FROM news ORDER BY newsId LIMIT 0,5") or die (mysql_error()); while($del=mysql_fetch_assoc($sql)){ $id = $del['newsId']; $content = $del['content']; $title = $del['title']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; ?> <?php mail( "[email protected]", "$title", $content, "$headers" ); $sql3="DELETE FROM news WHERE newsId='".$del['newsId']."'"; $res=mysql_query($sql3)or die (mysql_error()); } ?> It works great just like i wanted, sends 5 email from table 'news' based on ascending numbers in row 'newsId'. but i would like to make a change now, i would like the script to send one email each to different email id's from the row "email" in the table "emailaddress" randomly. So that in case there is only 3 rows of content in "news" table the email is sent to random 3 email address from the table "email address". I have tried lot of things but i just can't find any working solution. Link to comment https://forums.phpfreaks.com/topic/176002-solved-issues-with-my-email-script/ Share on other sites More sharing options...
RussellReal Posted September 30, 2009 Share Posted September 30, 2009 I'm sorry I really don't understand you.. try adding me to msn or aim we can communicate better that way. or try rephrasing yourself a bit better in your question Link to comment https://forums.phpfreaks.com/topic/176002-solved-issues-with-my-email-script/#findComment-927436 Share on other sites More sharing options...
ninjamonky Posted September 30, 2009 Author Share Posted September 30, 2009 thanks for your reply I was in a rush that time. I wanted my script to send 1 email each to the 5 random email id picked from fields in a row. I fixed it myself, just had to create a new variable for email id and call it inside the loop. Link to comment https://forums.phpfreaks.com/topic/176002-solved-issues-with-my-email-script/#findComment-927441 Share on other sites More sharing options...
RussellReal Posted September 30, 2009 Share Posted September 30, 2009 so problem solved? hit 'solved' oh and *admin like voice* Enjoy your stay at our lovely forums, and hope to hear from you again! haha even tho I'm not an admin admins get cool banners n stuff Link to comment https://forums.phpfreaks.com/topic/176002-solved-issues-with-my-email-script/#findComment-927444 Share on other sites More sharing options...
ninjamonky Posted September 30, 2009 Author Share Posted September 30, 2009 i was looking for such button, let me grab my nerd glasses and look closely. Link to comment https://forums.phpfreaks.com/topic/176002-solved-issues-with-my-email-script/#findComment-927455 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.