PHP - Mailing List Help
I have email's in mysql... how do i automatically send emails every week. I know how to send mail with php.
How do i automatically send it every week? Similar TutorialsHello, I know very little about PHP, i am a graphics and HTML guy , i had a simple mailing list script up on a clients page for a couple years, and now all of a sudden it has stopped working. When you enter your name, and email, you get "select fails" and it does not get added to the database. Here is the code, any help would be great, i am lost since nothign has changed, but it just stoppped working. from the config.php file Code: [Select] function insert_mail() { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $sql2="select * from mail where email='$email'"; $result2=mysql_query($sql2) or die("select fails"); $no=mysql_num_rows($result2); if ($no==0) { $sql = "insert into mail(id,fname,lname,email) values(NULL,'$fname','$lname','$email')"; $result = mysql_query($sql) or die("insert fails"); echo "Email added to list: " . LISTNAME; } else { echo "Email Address Already Exists in List: " . LISTNAME; } } function delete_mail() { $email = $_POST['email']; if ($email == "") { $email = $_GET['email']; } $sql2="select * from mail where email='$email'"; $result2=mysql_query($sql2) or die("select fails"); $no=mysql_num_rows($result2); if ($no==0) { echo "Your email was not found in the list: " . LISTNAME; } else { echo "Your email was unsubscribed from the list: " . LISTNAME; } $sql2="delete from mail where email='$email'"; $result2=mysql_query($sql2) or die("unsubscribe failed, please try again"); } ?> From the HTML Code: [Select] <center> <form action='<? echo BASEHREF; ?>index.php' method=post> <TABLE BORDER=0 ALIGN=center> <TR> <TD><b>first name</b></TD> <TD><INPUT TYPE=text name=fname></TD> </TR> <TR> <TD><b>last name</b></TD> <TD><INPUT TYPE=text name=lname></TD> </TR> <TR> <TD><b>email</b></tD> <TD><INPUT TYPE=text name=email></td> </tR> <TR> <TD colspan=2 align=center><INPUT TYPE=submit value=join> <INPUT TYPE=reset value=reset><BR></TD> </tR> </TABLE> </FORM> </center> Let me know what else you may need.... I have a mail list script, problem is if I have to many mails sent at one time my website will be suspended. What should I do? Hi, I am new to this forum and hopefully u guys can help me solve the problem i have in this first post! So please take a look at this html script <html> <head> <title>Sub/Unsub</title> </head> <body> <h1> Subscribe or unsubscribe mailing list</h1> <form method=POST action="manage.php"> <p><b>Your E-mail address:</b></br> <input type=text name="email" size=40 maxlength=150> <p><b>Action:</b></p> <input type=radio name="action" value="sub" checked>Subscrbie <input type=radio name="action" value="unsub">Unsubscribe <p><input type=submit name="submit" value="Submit form"></p> </form> </body> </html> And this is the manage.php script: <?php //set up a couple of functions include('connect.php'); function emailChecker($email){ global $connect, $check_result; //check mail is not already in list $check = "select id from users where email = '$email'"; $check_result = mysqli_query($connect, $check) or die(mysqli_error($connect)); } if ( ($_POST[action] == 'sub')){ //Try to subscribe, so validate email if($_POST[email]=""){ hearder("Location: manage_start.php"); exit(); } //connect to database db(); //check if email is on the list emailChecker($_POST[email]); //check the number of results to look for duplicates if (mysqli_num_rows($check_result)<1){ //since no records detected, so add this new email $sql="INSERT into users (email) values('$_POST[email]')"; $result = mysqli_query($connect, $sql) or die(mysqli_error($connect)); echo "<p>Thanks for signing up man!!</p>"; } else { //print failure message echo "<p>You have already subscribed!</p>"; } } else if (($_POST[action] == "unsub")){ //trying to unsubscribe and validate address if ($_POST[email] == "") { header ("Location: manage_start.html"); exit(); } db(); emailChecker($_POST[email]); if (mysqli_num_rows($check_result) <1) { //print failure message echo "<p>Cannot find your address!</p> <p>No action is taken</p>"; } else { //unsubscribe address $id = mysqli_real_escape_string($connect, $_POST['id']); $sql = "DELETE from users where id = '$id'"; $result = mysqli_query($connect, $sql) or die(mysqli_error()); echo "<p>You have unsubscribed!</p>"; } } ?> So wut i am trying to do in this script is to create a mailing list form for user to subscribe/unsubscribe using email address. When i first run the html script (which includes php script) and subscribe by the first time, it went perfectly fine and it echos "thanks for signing up man!!" but when i try it with the totally DIFFERENT email address, it always says "You have already subscribed!!" Even when i put blank on the address box, it still shows "You have already subscribed!!" Also it's the same deal as unsubscribe, first time i could delete an entry from my database completely, but afterward when i try to delete the exact email addresses from database, it wouldn't work !! It just says "You have unsubscribed!" but when i checked back if the entry has been deleted, the answer is NO ! I am wondering if this is the problem about $global values under function emailChecker( ). Btw my database connection works absolutely fine. I know this is a long ass post but i need an urgent answer PLZZZZZZZZ Hi guys, I was just wondering if anyone could help me. I've got a My_SQL database containing articles, a summary for the article and a date. I have a basic CMS system set-up, but I want to create a script that when users sign up to a mail list it forwards the summary and dates of the articles database. If that makes sense? But I only want it to forward the most recent 5 rows. I'm pretty new to PHP and I've been mostly following tutorials thus far, but this is quite specific. Thanks in advance! <?php //Database Credentials include "../db_fns.php"; session_start(); //Database connection $conn = db_connect_2(); if (isset($_SESSION['link']) AND !isset($_POST['Submit'])){ //retrieve link if(is_string($_SESSION['link'])){ $link = unserialize($_SESSION['link']); } else { $link = $_SESSION['link']; } if($link){ //basic stuff $_SESSION['transgene_type'] = (string)$link->tt_id; $_SESSION['promoter_locus'] = $link->promoter; $_SESSION['PromoLocusSynonyms'] = $link->pl_synonyms; $_SESSION['species'] = (string)$link->s_id; //genetic background //clear it just incase there are values since another time $_SESSION['genetic_bg'] = array(); $_SESSION['GeneticBGOtherTxt'] = ""; foreach($link->genetic_bg as $gbg){ //we check if it is a menu selected item or an item that is not in menu if((int)$gbg['GBG_IS_MENU']){ $_SESSION['genetic_bg'][] = $gbg['GBG_ID']; } else { //belongs in other if(empty($_SESSION['GeneticBGOtherTxt'])) { $_SESSION['GeneticBGOtherTxt'] .= $gbg['GBG_NAME']; } else { $_SESSION['GeneticBGOtherTxt'] .= ",".$gbg['GBG_NAME']; } } } $_POST = $_SESSION; }elseif (isset($_POST['Submit'])) { if(isset($_SESSION['link'])) { //we need to unserialize the link if(is_string($_SESSION['link'])){ $link = unserialize($_SESSION['link']); //unserialize() takes a single variable and converts it back into a php value } else { $link = $_SESSION['link']; } } //put $_POST variables into $_SESSION $_SESSION = $_POST + $_SESSION; unset($_SESSION['Submit']); // CHECK FOR ERRORS AFTER SUBMISSION $errors = array(); // Set array if (!$_POST['promoter_locus']) $errors[] = "Please specify a value for \"Promoter or Locus\"".$PromoLocus; if (!$_POST['transgene_type']) $errors[] = "Please specify a value for \"Transgene Type\""; if (!$_POST['inducible_systems'] && !$_POST['InducibleSystemsOther']) $errors[] = "Please specify an \"Inducibility\" value"; } if (count($errors) > 0 ) { $iferrors = "Yes"; } else { [SIZE="4"][B][U] include ('mailing_list.php'); checkPromoter($_POST['promoter_locus'];[/U][/B][/SIZE] //this is to check that step one has been completed once we go to step 2 $_SESSION['step'] = 2; header("Location: StepTwo_2.php"); exit; } } } else { session_trash_(); session_regenerate_id(true); } Note that this script is an excerpt and I make the lines that I put to be bold and underlined. This is the mailing_list.php <?php require('connection.php'); function checkPromoter ($_POST['promoter_locus']) { $check = "select id from mailing_list where query = '$_POST['promoter_locus']'"; $result = mysqli_query($connect, $check) or die(mysqli_error($connect)); if (mysqli_num_rows($result)==0){ continue; } else { $sql = "select email from mailing_list where query = '$_POST['promoter_locus']'"; $query = $_POST['promoter_locus']; $email = mysqli_query($connect, $sql) or die(mysqli_erro($connect)); $to = $email; $subject = "The query is updated"; $headers = "From: asdfasdf"; $body = " Hello This is to inform you that $query is updated, please go to this link to search for it: http://asdfasdf Regards, asdfasdf."; mail($to, $subject, $body, $headers); die(); } } So my questions are 1. Where should I place those bold lines in addEntry.php? I tried to run it but the result is a blank page... Also there's no email sending through to my test email 2. For the line function checkPromoter ($_POST['promoter_locus']), should I put variable like $promoter = $_POST['promoter_locus'] ? Cuz I ran that and the error is Parse error: syntax error, unexpected '[', expecting ')' 3. Can u guys please help me fix up mailing_list.php? thanks for ur patience to read thru this and ANY HELP IS APPCRECIATED :p Hi I have been given a task to create some SQL reports. One of the reports is to display all the customers who have purchased a certain product based on user selection and then have those results able to be extracted to a mailing list. So ive got the report done. Some drop down boxes allow a user to select a product and once submitted the results are then displayed. But i dont even know where to begin with extracting those results to a mailing list. Could someone help me please? What method should I use? and where do i begin? BTW im a rookie with PHP/Mysql ive just got my first job since leaving university and this is a task ive been given at work so any quick and helpful replies are greatly appreciated Thanks in advance. Hi all, I have a problem with emailing php code using a php function. using the code below, It emails the message 2 times with blank content. I think the problem might be with the eval() or file_get_content(), because if I comment it out the eval() and replace $message with a static value, it sends the message once with the static content. The functions safeText (which does a mysql_real_escape_string), returnShopName (which returns the shop name) and returnShopEmailURL(which returns the url of the shop minus the http://www) all work, as they are used in other functions. here is the function: Code: [Select] <?php //Email a link to the voucher function emailVoucher($id) { //Ensure no one can use a combined URL and SQL Injection attack, as it comes from a $_GET $id = safeText($id); //Query the database, count the results and make an array to hold them $query = mysql_query("SELECT * FROM shop_vouchers WHERE voucher_id = '".$id."' LIMIT 1") or die ('Error: '.mysql_error()); $count = mysql_num_rows($query); $fetch = mysql_fetch_array($query); //If there are results if($count == 1) { $to = $fetch["voucher_email"]; $subject = 'Your voucher from '.returnShopName(); $headers = 'From: website@'. returnShopEmailURL() . "\r\n" . 'Reply-To: no-reply@'. returnShopEmailURL() . "\r\n" . 'X-Mailer: PHP/' . phpversion() . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html' . "\r\n"; $link = 'http://www.example.com/vouchers.php?email=1'; $name = returnShopName(); $URL = returnShopEmailURL(); $body = file_get_contents('includes/voucher_email.php'); eval("\$body = \"$message\";"); mail($to, $subject, $message, $headers); gotoURL("vouchers.php?issue=1"); }else{ //Popup error message and redirect echo '<script type="text/javascript">'; echo 'alert("An error occurred. Please try again.")'; echo '</script>'; gotoURL("vouchers.php"); } } ?> the code in voucher_email.php (for testing purposes) is: Code: [Select] $name 1, $link 2, $URL 3 First off, hello. This is my first pHp code, and still tying to get a grasp on it all. This is the pHp i have for my mailing form. Now i wish to make the user have to put in a valid email address. Except it isn't working for me. The following script isn't coming up with any errors, but it is still letting the email field be submitted with any text. <?php if ($_POST['submit']) { $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; $errorstring = ""; if (!$name) $errorstring = $errorstring."Name<br>"; if (!$email) $errorstring = $errorstring."email<br>"; if (!$comments) $errorstring = $errorstring."comments<br>"; if ($errorstring!="") echo "You missed the following:<br>$errorstring"; else { $webMaster = "name@site.com"; $emailSubject = "Contact Us Form"; $mail_from = "$email"; $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; function valid_email($email) { if(eregi("^[\w\-]+?\@\w+?\.\w+$", $email)) { return TRUE; } else { return FALSE; } } if (!valid_email($email)) { die('bad email'); } $body = ' <br> Name ' . $name . ' <br><br> ' . $email . ' <br><hr><br> Comments<p> ' . $comments . ' '; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); $redirect = file_get_contents('redirect.html'); echo $redirect; } } ?> Thank you. I'm trying to send an email that has a list created from a while loop to multiple people with an email list created from while loop. Can someone please help me figure this out? My brain is fried. Here's the code that I have: This is producing an error message that reads: Parse error: syntax error, unexpected '{' in /home/content/29/6879529/html/calhoun/admin/sendreport.php on line 22 Code: [Select] <?php include("conf.inc.php"); $result = mysql_query("SELECT `prefix`,`lname`,`email` FROM admin"); $row = mysql_fetch_row($result); $result2 = mysql_query("SELECT `to`,`from`,`subject`,`message`,`date` FROM allmsgs WHERE reported = 'n' ORDER BY `messid` ASC"); $row2 = mysql_fetch_row($result2); $cdate = date('m-d-Y'); while ($row = mysql_fetch_row($result)) { $prefix = $row[0]; $lname = $row[1]; $adminemail = $row[2]; $fullname = "$prefix $lname"; $sendto = "$adminemail"; $emailsubject = "Webstats Report For $cdate."; while ($row2 = mysql_fetch_row($result2){ // This is line 22. $to = $row2[0]; $from = $row[1]; $subject = $row[2]; $message = $row[3]; $datetime = $row[4]; $eachmessage = "<p> <hr width=\"400\"> To: $to<br> From: $from<br> On $datetime<br> <br> $subject<br>$nbsp;<br> $message </p>"; } $emailmessage = "<html> <body> $fullname, <p> Here is a list of the messages that have been exchanged in the last 24 hours.</p> $eachmessage </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Webstats <reports@webstats.com>' . "\r\n"; // Mail it mail($sendto, $emailsubject, $emailmessage, $headers); } ?> Hey everyone I'm pretty new at PHP so i'm hoping someone can help me with this code. What I am trying to do is if someone selects a state say Kansas then fills out the rest of the form and clicks submit it will go to a specific email address. If someone selects another state like Nebraska it will go to a separate email address. Here is my code and I hope someone can help me with this. PS I think I really screwed this one up lol :help: Thanks, B Code: [Select] <?php /* Subject and Email variables */ $emailSubject = 'Your Car Report Info.'; $webMaster = 'me@rustyeckford.com'; $webMaster2 ='me1@rustyeckford.com'; $webMaster3 ='me2@rustyeckford.com'; /* Gathering Data Variables */ $f_nameField = $_POST['f_name']; $l_nameField = $_POST['l_name']; $addField = $_POST['Address']; $stateField = $_POST['state']; $phoneField = $_POST['phone']; $emailField = $_POST['email']; $vinField = $_POST['vin']; $body = <<<EOD <br><hr><br> First Name: $f_name <br> Last Name: $l_name <br> Address: $Address <br> State: $state <br> Phone: $phone <br> Email: $email <br> VIN: $vin <br> EOD; switch($state) { case 'Kansas': case 'Oklahoma': $wm = $webMaster2; break; case 'Missouri': case 'Iowa': $wm = $webMaster3; break' case 'Nebraska: $wm = $webMaster; break; } $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($wm, $emailSubject, $body, $headers); /* Results rendered from Html */ $theResults = <<<EOD <html> <head> <title>Your Car Report - Results</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } </style> </head> <div> <div align="center">Thank you for your submission. Your vehicle report will be provided to you very soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> Hi, PHP beginner here.
I'm trying to run a very basic script which does the following:
1) Input some data into a form
2) Outputs the data onto the screen
3) Click submit and e-mail it to me.
The purpose of it is simply to learn how to input some data, output that data along with some basic calculations and then to send that data to an e-mail address.
#1 & #2 I can do. I can enter some text and some numbers and on the next screen I can print a message containing the data I put into the form.
Also I am taking the variables and doing some calculations which is fine.
However, when I click submit (on the second screen) to e-mail the data to me, I am getting an e-mail but none of the variables have retained the data.
FORM
<html> I'm using 3 files to try and mass mail my members, massmail.php massmail-exe.php and elist.php massmail.php <form name="massmail" method="post" action="./massmail-exe.php"> <table width="450px"> <tr> <td valign="top"> <label for="subject">Subject</label> </td> <td valign="top"> <input type="text" name="subject" maxlength="50" size="30" id="subject"> </td> </tr> <tr> <td valign="top"> <label for="message">Email Content</label> </td> <td valign="top"> <textarea name="message" maxlength="9001" cols="100" rows="18" id="message"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> </td> </tr> </table> </form> massmail-exe.php <?php // read the list of emails from the file. $email_list = file("./elist.php"); // count how many emails there are. $total_emails = count($email_list); // go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } // implode the list into a single variable, put commas in, apply as $to value. $to = implode(",",$email_list); if ( mail($to,$_POST["subject"],$_POST["message"]) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> and elist.php which has the email addresses. What is wrong because every time i try and send it it say query failed. Thanks so much. Somebody please tell me why this wont work. Didnt wont to put my email in their. <?php $user = $_POST['subject']; $email = $_POST['email']; $message = $_POST['message']; //To, Subject, Message mailto(''); mailsubject('$user Sent you a message'); mailfrom('From: ' . $user . ' <' . $email . '>'); ?> Hey, been trying to make a form to upload an image to the server and also email the image as attachment. After nearly a week I managed to make it work. Only some validation needs to be done. My next step is to make it work for multiple files, ie. 5. The form will have 5 boxes to upload images and no more. I have tried a few different things with for loops ( ie for $i=0; $i<5; $i++ {...} ) but no luck. I can't think of any solution of a loop to upload multiple files and then email multiple attachment as my code. The code is: <?php session_start(); $imagename1 = $_FILES["uploadFile1"]["name"]; $_SESSION['imagename1'] = $imagename1; $imagename1 = $_SESSION['imagename1']; $imagetype1 = $_SESSION['imagetype1']; $imagesize1 = $_SESSION['imagesize1']; $imagetemp1 = $_SESSION['imagetemp1']; $thankyouurl = 'thankyou.php' ; $errorurl = 'error.php' ; $http_referrer = getenv( "HTTP_REFERER" ); $http_agent = getenv( "HTTP_USER_AGENT" ); $domain = $_SERVER['REMOTE_ADDR']; $filename = $_SESSION['uploadFilename']; if(isset($_POST['send'])) { $fp = fopen($imagetemp1, "rb"); $file = fread($fp, $imagesize1); $file = chunk_split(base64_encode($file)); $num = md5(time()); fclose($fp); // UPLOAD FILE // possible PHP upload errors $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); // check the upload form was actually submitted else print form isset($_POST['send']) or error('the upload form is neaded', $uploadForm); // check for standard uploading errors ($_FILES[$fieldname1]['error'] == 0) or error($errors[$_FILES[$fieldname1]['error']], $uploadForm); // check that the file we are working on really was an HTTP upload @is_uploaded_file($_FILES[$fieldname1]['tmp_name']) or error('not an HTTP upload', $uploadForm); // validation... since this is an image upload script we // should run a check to make sure the upload is an image @getimagesize($_FILES[$fieldname1]['tmp_name']) or error('only image uploads are allowed', $uploadForm); // make a unique filename for the uploaded file and check it is // not taken... if it is keep trying until we find a vacant one $now = date("y-m-d_H-i-s", time()); while(file_exists($uploadFilename = $uploadsDirectory.$now.'_'.$_FILES[$fieldname1]['name'])) { $now++; } // now let's move the file to its final and allocate it with the new filename @move_uploaded_file($_FILES[$fieldname1]['tmp_name'] , $uploadFilename) or error('receiving directory insuffiecient permission', $uploadForm); $from= 'youremail@server.co.uk'; $emailTo = 'mail@hotmail.com'; $subject = 'Quote Form'; $body = "equipment_type: $equipment_type \n\nModel: $Model \n\nMake: $Make \n\nModelNumber: $ModelNumber"; $fp = $_SESSION['fp']; $file = $_SESSION['file']; $num = "==Multipart_Boundary_x{$semi_rand}x".$_SESSION['num']; $headers = 'From: Name <'.$from.'>' . "\r\n" . 'Reply-To: ' . $emailTo; //Normal headers $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$body."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$imagetype1." "; $headers .= "name=\"".$imagename1."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$imagename1."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; mail($emailTo, $subject, $body, $headers); header( "Location: $thankyouurl" ); } ?> the form is like this Code: [Select] <input name="uploadFile1" id="uploadFile1" value="" class="file" type="file"/>can anyone suggest anything please? how can I form the for statement? much appreciated what I am trying to do is use this php script to load the data being submitted in the html form into my database and then populate the database into an excel (xls) file and then e-mail it to my address. Everything works great it populates into the database and creates the xls file perfect. But it is wanting me to download the file. What can I add to the script to have it e-mail the file to my e-mail address INSTEAD of downloading it. Code: [Select] <?php define('DB_NAME', 'database'); define('DB_USER', 'username'); define('DB_PASSWORD', 'password'); define('DB_HOST', 'hostname'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die('Can\'t use ' . DB_NAME . ': ' . mysql_error()); } $value1 = $_POST['groupname']; $value2 = $_POST['name']; $value3 = $_POST['address']; $value4 = $_POST['city']; $value5 = $_POST['state']; $value6 = $_POST['zip']; $value7 = $_POST['homephone']; $value8 = $_POST['cellphone']; $value9 = $_POST['email']; $value10 = $_POST['age']; $value11 = $_POST['maritalstatus']; $value12 = $_POST['income']; $value13 = $_POST['contact1']; $value14 = $_POST['contact2']; $value15 = $_POST['contact3']; $value16 = $_POST['date1']; $value17 = $_POST['date2']; $value18 = $_POST['date3']; $sql = "INSERT INTO clients (groupname, name, address, city, state, zip, homephone, cellphone, email, age, maritalstatus, income, contact1, contact2, contact3, date1, date2, date3) VALUES ('$value1', '$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8', '$value9', '$value10', '$value11', '$value12', '$value13', '$value14', '$value15', '$value16', '$value17', '$value18')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close(); mysql_connect('hostname', 'username', 'password'); mysql_select_db('database'); $sql = "SELECT `groupname` AS `Group`, `name` AS `Customer Name`, `address` AS `Address`, `city` AS `City`, `state` AS `State`, `zip` AS `Zip Code`, `homephone` AS `Home Phone`, `cellphone` AS `Cell Phone`, `email` AS `E-Mail`, `age` AS `Age Group`, `maritalstatus` AS `Marital Status`, `income` AS `Household Income`, `contact1` AS `Contact VIA`, `contact2` AS `Contact VIA`, `contact3` AS `Contact VIA`, `date1` AS `1st Date`, `date2` AS `2nd Date`, `date3` AS `3rd Date` FROM fundtour_info.clients clients"; // Query Database $result=mysql_query($sql); $filename = 'file.xls'; // Send Header header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download");; header("Content-Disposition: attachment;filename=$filename"); header("Content-Transfer-Encoding: binary "); // XLS Data Cell xlsBOF(); xlsWriteLabel(0,0,"Group"); xlsWriteLabel(0,1,"Name"); xlsWriteLabel(0,2,"Address"); xlsWriteLabel(0,3,"City"); xlsWriteLabel(0,4,"State"); xlsWriteLabel(0,5,"Zip Code"); xlsWriteLabel(0,6,"Home Phone"); xlsWriteLabel(0,7,"Cell Phone"); xlsWriteLabel(0,8,"E-mail Address :"); xlsWriteLabel(0,9,"Age Group"); xlsWriteLabel(0,10,"Marital Status"); xlsWriteLabel(0,11,"Income"); xlsWriteLabel(0,12,"Contact Via"); xlsWriteLabel(0,13,"Dates"); $xlsRow = 1; while(list($groupname,$name,$address,$city,$state,$zip,$homephone,$cellphone,$email,$age,$maritalstatus,$income,$contact1, $contact2, $contact3,$date1, $date3, $date3)=mysql_fetch_row($result)) { ++$i; xlsWriteLabel($xlsRow,0,"$groupname"); xlsWriteLabel($xlsRow,1,"$name"); xlsWriteLabel($xlsRow,2,"$address"); xlsWriteLabel($xlsRow,3,"$city"); xlsWriteLabel($xlsRow,4,"$state"); xlsWriteLabel($xlsRow,5,"$zip"); xlsWriteLabel($xlsRow,6,"$homephone"); xlsWriteLabel($xlsRow,7,"$cellphone"); xlsWriteLabel($xlsRow,8,"$email"); xlsWriteLabel($xlsRow,9,"$age"); xlsWriteLabel($xlsRow,10,"$maritalstatus"); xlsWriteLabel($xlsRow,11,"$income"); xlsWriteLabel($xlsRow,12,"$contact1, $contact2, $contact3"); xlsWriteLabel($xlsRow,13,"$date1, $date3, $date3"); $xlsRow+++; } xlsEOF(); exit(); function xlsBOF() { echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); return; } function xlsEOF() { echo pack("ss", 0x0A, 0x00); return; } function xlsWriteNumber($Row, $Col, $Value) { echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); echo pack("d", $Value); return; } function xlsWriteLabel($Row, $Col, $Value ) { $L = strlen($Value); echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); echo $Value; return; } ?> Thanks for any help Hi, In my mysql database i have a text input option, in the registration form and edit my details form i have a multiple select dropdown list, which user selects options to populate the text input box, which ultimately populates the text field in the mysql database. All works perfectly. The dropdownlist consists of 3 parts <optgroups> first is current selection (what is the usesr current selection)works fine, The second <optgroup> is existing words, what words we(the site) have given as options, and the third <optgroup> is the words that others have used. This is where im having a small problem. Because its a text field when i call the data from the database, it calls the entire text box as a single option in my select list.. I want to break the words in the text field (at the comma) and have them listed each one as an option in the select list. Example what i need: Words in text box:(my input allows the "comma") word1, word2, word3, word4, word5, word6, How i want them called/displayed: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> here's my code: $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $original_functionsexperience =doSelectSql($query,1); $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $functionsexperiencelist=doSelectSql($query); $funcexpList ="<select multiple=\"multiple\" onchange=\"setFunctionsexperience(this.options)\">"; foreach ($functionsexperiencelist as $functionsexperienceal) { $selected=""; if ($functionsexperienceals->allwords == $original_functionsexperience) $selected=' selected="selected"'; $allwords=$functionsexperienceal->allwords; $funcexpList .= "<optgroup label=\"Current selection\"> <option value=\"".$allwords."\" ".$selected." >".$allwords."</option> </optgroup> <optgroup label=\"Existing Words\"> <option value=\"existing1,\">existing1</option> <option value=\"existing2,\">existing2</option> <option value=\"existing3,\">existing3</option> <option value=\"existing4,\">existing4</option> <option value=\"existing5,\">existing5</option> <option value=\"existing6,\">existing6</option> </optgroup> <optgroup label=\"Others added\"> //heres problem <option value=\"".$allwordsgeneral."\">".$allwordsgeneral."</option> </optgroup>"; } $funcexpList.="</select>"; $output['FUNCEXPLIST']=$funcexpList; The result im getting for optgroup others added: word1, word2, word3, word4, word5, how can i get it like this: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> Hi , I have one question .. Can I split showing of content of dynamic list in 2 parts , when I echo list in code .. Code: [Select] <?php // Run a select query to get my letest 8 items // Connect to the MySQL database include "../connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 8"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<table width="100%" border="2" cellspacing="2" cellpadding="2"> <tr> <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="2" /></a></td> <td width="83%" valign="top">' . $product_name . '<br /> $' . $price . '<br /> <a href="product.php?id=' . $id . '">View Product Details</a></td> </tr> </table>'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Code: [Select] <p><?php echo $dynamicList; ?><br /> </p> It works ok, and putting my files, everything works, but when I put 8 pictures with price and other details, it just show one image with details and another image below with details, and the third image below and so on .. Can I split dynamic list to show 4 images with details on the left side and 4 on the right side? Thank you in advance for help , if is possible Hi, I use the following code to create a select menu from an array of options stored in LISTS.php: include 'LISTS.php'; print('<select id="from" name="from">'); foreach ($langList as $lang) {printf('<option %s>%s</option>', ($from1 == $lang ? 'selected="selected"' : ''), $lang); } echo '</select>'; where LISTS.php includes the following: $langList = array(' ','English', 'French', 'German', 'Dutch', 'Spanish'); This works great, but now I want to do something similar with a checkbox list, where each checkbox has an associated 'onchange' javascript function and I'm getting pretty stuck. My checkbox list is of the following form: Code: [Select] <html> <ul style="height: 95px; overflow: auto; width: 200px; border: 1px solid #480091; list-style-type: none; margin: 0; padding: 0;"> <li id="li1b"><label for="chk1b"><input name="chk1b" id="chk1b" type="checkbox" onchange="function1('chk1b','li1b')">Option1</label></li> <li id="li2b"><label for="chk2b"><input name="chk2b" id="chk2b" type="checkbox" onchange="function1('chk2b','li2b')">Option2</label></li> //etc. </ul> </html> What I want to do is have 'Option1', 'Option2', etc. stored in an array in LISTS.php and have a PHP script that populates the checkbox list accordingly, in a similar manner to my select menu above. I can't work out how to get the ID of the next <li> and the next <input> in the list to go up by one each time, e.g. 'li1b' then 'li2b', 'li3b', etc. Could someone pls help me out? Thanks! Is there a way to take data that is listed like a,b,c,d,e and turn that into an unordered list? Basically, I'm going to have a list of schools that will be listed with comma separators. I'll print that data out in two places, one will be printed as it's in the database. The other I would like to echo as an unordered list. |