Hi, i was wondering if anyone could give me some help…
I’ve created a script that emails a list of contacts in a database, so far it’s working perfectly, i’m just left scratching my head trying to put a few variables in the message body… I’ll attach my code below so if you could give me any advice that would be great.
I’ve got one variable in the message at the moment, but would basically like to set up a $message variable that pulls the variables from the first query and puts them into a user friendly email message.
I’m not asking for full code, maybe just a short example??
Also, how would i go about changing the status of the row that is in $req_id = $_GET[‘id’]; once the email has been sent out?
Thanks very much…
[php]
<?php session_start(); // Are we logged in? if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) { // If we're not logged in, piss off to the login page header('Location: login.php'); exit; } // Get the request id from the previous selection $req_id = $_GET['id']; // Set mail prefs $subject = Part Request'; $headers = 'From: Whoever n'; // Get the data for that request from the database $dbid = mysql_connect ('localhost', 'username', 'password'); mysql_select_db('database',$dbid) or die ("Cannot find database"); $query = "SELECT * FROM request_data WHERE req_id = $req_id"; $result = mysql_query($query,$dbid) or die("SELECT error:".mysql_error()); while($row = mysql_fetch_array($result)) { $request_id = $row['req_id']; $manufacturer = $row['manufacturer']; $model = $row['model']; $capacity = $row['capacity']; $year = $row['year']; $part_one = $row['part_one']; $part_two = $row['part_two']; $part_three = $row['part_three']; $part_four = $row['part_four']; $part_five = $row['part_five']; $full_name = $row['full_name']; $telephone = $row['telephone']; $alt_telephone = $row['alt_telephone']; $email = $row['email']; $area = $row['area']; $comments = $row['comments']; } mysql_close($con); // Get the email addresses, depending on active status $dbid = mysql_connect ('localhost', 'username, 'password'); mysql_select_db('database',$dbid) or die ("Cannot find database"); $query = "SELECT requests FROM breakers WHERE active='yes'"; $result = mysql_query($query,$dbid) or die("SELECT error:".mysql_error()); while($row = mysql_fetch_array($result)) { set_time_limit(0); $request_subs = $row['requests']; mail("$request_subs", $subject, $part_one, $headers); echo 'test'; } mysql_close($con); ?>[/php]