ActaNonVerba1 Posted January 14, 2011 Share Posted January 14, 2011 Hey guys Whats the best way to take all the email addresses from a MySQL database of contact information and turn it into an array which i can use in the To: Section of sending an email in php? Thanks. Link to comment https://forums.phpfreaks.com/topic/224461-best-way-to-take-all-the-email-addresses-from-a-mysql-database-then/ Share on other sites More sharing options...
BlueSkyIS Posted January 14, 2011 Share Posted January 14, 2011 select `email` from contact_table, loop over results adding each to an array. Link to comment https://forums.phpfreaks.com/topic/224461-best-way-to-take-all-the-email-addresses-from-a-mysql-database-then/#findComment-1159526 Share on other sites More sharing options...
ActaNonVerba1 Posted January 14, 2011 Author Share Posted January 14, 2011 Can you provide a code example please? Im very new, and havnt really used arrays yet in any great detail.... Thanks Link to comment https://forums.phpfreaks.com/topic/224461-best-way-to-take-all-the-email-addresses-from-a-mysql-database-then/#findComment-1159531 Share on other sites More sharing options...
BlueSkyIS Posted January 14, 2011 Share Posted January 14, 2011 can we see what you've got so far, connecting to database and completing the query. and what you've tried as far as filling the array. Link to comment https://forums.phpfreaks.com/topic/224461-best-way-to-take-all-the-email-addresses-from-a-mysql-database-then/#findComment-1159534 Share on other sites More sharing options...
ActaNonVerba1 Posted January 14, 2011 Author Share Posted January 14, 2011 <?php session_start(); if ($_SESSION['adminlogin'] == 1){ //Run } else { header('Location: Log-In.php'); exit; } $title = $_POST['title'] ?> <!DOCTYPE HTML> <html lang="en-GB"> <head> <meta charset="utf-8"> <!--Search Engine Meta Tags--> <meta name="author" content="Worldwide Lighthouses"> <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel"> <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships"> <!--Stylesheets/Javascript--> <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)"> <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)"> <!--Mobile Browser Support--> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <!--IE Support--> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]--> <meta name="application-name" content="Worldwide Lighthouses"> <meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> <meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> <meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> <meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> <meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> <meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico"> <title>Email Sent | Worldwide Lighthouses</title> </head> <body> <header> <h1 id="WWLH">Worldwide Lighthouses</h1> <form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box"> <input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off"> <input type="submit" value="Search"> <input type="hidden" name="search" value="1"> </form> </header> <nav> <ul id="Nav"> <li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li> <li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li> <li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li> <li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li> <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li> <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li> <li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li> </ul> </nav> <?php if ($_SESSION['adminlogin']==1) { echo '<div id="logout"> <div style="float:left; width:30%; text-align:left;!important"> <a href="Log-In-Accept-Deny.php">Back to Admin Home</a> </div> <div style="float:right; width:70%;"> <a href="Logout.php">Log Out of Admin</a> <p style="font-size:10px;">Always Sign Out when Finished!</p> </div></div>';} ?> <article> <h1 class="Title">Update Contact Record</h1> <div class="Textbox"> <?php $user="worldw44_php"; $password="c@rtmeldrive41"; $database="worldw44_newsemail"; mysql_connect(localhost,$user,$password); @mysql_select_db($database) or die( "Unable to select database, please try again later."); $query = "SELECT * FROM contactinfo"; $result = mysql_query($query) or die(mysql_error());; $row = mysql_fetch_array($result) or die(mysql_error()); echo 'email'. " - ". $row['email']; $emailcontent = $_SESSION['email']; ################################################# ############ EMAIL HEADERS & SEND ############### ################################################# $to = "[email protected]"; $subject = "$title"; $message = "$emailcontent"; $from = "[email protected]"; $headers = "From: [email protected]\r\n"; $headers .= "Reply-To: [email protected]\r\n"; $headers .= "Return-Path: [email protected]\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; mail($to,$subject,$message,$headers); echo 'Email sent.<br>'; echo '<a href="Admin.php">Go Back to Contact Admin Centre</a><br><br>'; ?> </div> </article> <footer> <ul> <li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li> <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li> <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li> <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li> <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li> <li><a href="#Top">Back to top</a></li> </ul> <br> <br> © Worldwide Lighthouses <?php echo date("Y"); ?> </footer> </body> Thats what i have so far.... Link to comment https://forums.phpfreaks.com/topic/224461-best-way-to-take-all-the-email-addresses-from-a-mysql-database-then/#findComment-1159555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.