I want 3 random images, first is working, but the other two just won't work.
Preferably, I want to pick 2 other images then the first and the second, and the third to be all different.
Here's my code:
$content .= '<div>';
$qryFirstImage = "SELECT a.KW, a.KWKidsBeschrijving, a.Titel, b.GebruikersNaam
FROM tblKWKids AS a
LEFT JOIN tblUser AS b
ON a.UserID = b.UserID
ORDER BY RAND()";
if ($stmt = mysqli_prepare($dbconn, $qryFirstImage)) {
mysqli_stmt_bind_result($stmt, $KW, $KWKidsBeschrijving, $TitelKW, $GebruikersNaam);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
mysqli_close($dbconn);
}
$content .= '<img src="' . $KW . '" width="240px" height="240px" alt="' . $TitelKW . '" title="' . $TitelKW . '">';
$content .= '<h5>' . $TitelKW . ' door: ' . $GebruikersNaam . '</h5>';
$content .= '<p>' . $KWKidsBeschrijving . '</p>';
$content .= '</div>';
$content .= '<div>';
$qrySecondImage = "SELECT a.KW, a.KWKidsBeschrijving, a.Titel, b.GebruikersNaam
FROM tblKWKids AS a
LEFT JOIN tblUser AS b
ON a.UserID = b.UserID
ORDER BY RAND()";
if ($stmt2 = mysqli_prepare($dbconn, $qrySecondImage)) {
mysqli_stmt_bind_result($stmt2, $KW2, $KWKidsBeschrijving2, $TitelKW2, $GebruikersNaam2);
mysqli_stmt_execute($stmt2);
mysqli_stmt_fetch($stmt2);
}
$content .= '<img src="' . $KW2 . '" width="240px" height="240px" alt="' . $TitelKW2 . '" title="' . $TitelKW2 . '">';
$content .= '<h5>' . $TitelKW2 . ' door: ' . $GebruikersNaam2 . '</h5>';
$content .= '<p>' . $KWKidsBeschrijving2 . '</p>';
$content .= '</div>';
$content .= '<div>';
$qryThirdImage = "SELECT a.KW, a.KWKidsBeschrijving, a.Titel, b.GebruikersNaam
FROM tblKWKids AS a
LEFT JOIN tblUser AS b
ON a.UserID = b.UserID
ORDER BY RAND()";
if ($stmt3 = mysqli_prepare($dbconn, $qryThirdImage)) {
mysqli_stmt_bind_result($stmt3, $KW3, $KWKidsBeschrijving3, $TitelKW3, $GebruikersNaam3);
mysqli_stmt_execute($stmt3);
mysqli_stmt_fetch($stmt3);
}
$content .= '<img src="' . $KW3 . '" width="240px" height="240px" alt="' . $TitelKW3 . '" title="' . $TitelKW3 . '">';
$content .= '<h5>' . $TitelKW3 . ' door: ' . $GebruikersNaam3 . '</h5>';
$content .= '<p>' . $KWKidsBeschrijving3 . '</p>';
$content .= '</div>';
Please look at those
php.net/mysqli_stmp::fetch
php.net/mysqli_stmt::close
Wrote very little code, search and much more.
$qryFirstImage = "SELECT a.KW, a.KWKidsBeschrijving, a.Titel, b.GebruikersNaam
FROM tblKWKids AS a
LEFT JOIN tblUser AS b
ON a.UserID = b.UserID
ORDER BY RAND()";
if ($stmt = mysqli_prepare($dbconn, $qryFirstImage)) {
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $KW, $KWKidsBeschrijving, $TitelKW, $GebruikersNaam);
for($i = 0; ($i < 3 && mysqli_stmt_fetch($stmt)); $i++){
$content .= '<div>';
$content .= '<img src="' . $KW . '" width="240px" height="240px" alt="' . $TitelKW . '" title="' . $TitelKW . '">';
$content .= '<h5>' . $TitelKW . ' door: ' . $GebruikersNaam . '</h5>';
$content .= '<p>' . $KWKidsBeschrijving . '</p>';
$content .= '</div>';
}
mysqli_stmt_close($stmt);
}
Related
I'm trying to display multiple posts, each with its own multiple comments. This, below, works for the first post (or, at least shows 2 of the 3 comments), but not for the rest. I searched but couldn't find (or didn't recognize) an answer to this exact problem on this site, or elsewhere. Thanks.
$result1 = #mysql_query('select * from posts,comments where comment_post_ID = ID and post_status="publish" and comment_approved="1" ORDER BY post_date,category,subcat1,subcat2 ASC');
$result2 = #mysql_query('select * from comments where comment_approved="1" ORDER BY comment_date');
$row = mysql_fetch_array($result1);
$row2 = mysql_fetch_array($result2);
while ($row = mysql_fetch_array($result1)) {
$post = $row['post_content'];
$id = $row['ID'];
$title = $row['post_title'];
$content = "<br /><h3 align=\"left\">" . $title . "</h3>\n";
$content .= "<h4 align=\"left\">by " . $row['post_author'] . " - " . $row['post_date'] . "</h4>\n";
$content .= "<p align=\"left\">" . var_export($post, true) . "</p>\n<p>\n";
echo $content;
while ($row2 = mysql_fetch_array($result2)) {
$comment = "<blockquote>";
$comment .= "<h4 align=\"left\">" . $row2['comment_author'] . " commented on " . $row2['comment_date'] . "</h4>\n";
$comment .= "<p align=\"left\">" . $row2['comment_content'] . "</p>\n<p>\n";
$comment .= "</blockquote>";
if($row2['comment_post_ID'] == $id) {
echo $comment;
}
}
}
This, below, finally worked as hoped:
$postData = mysqli_query($conn,"SELECT * FROM wp_posts ORDER BY post_date ASC) or die(mysqli_error());
$commentData = mysqli_query($conn,"SELECT * FROM wp_comments WHERE comment_approved = '1' ORDER BY comment_date ASC") or die(mysqli_error());
$posts = array();
while($row = mysqli_fetch_assoc($postData)) {
$posts[] = $row;
$commentrow = mysqli_fetch_assoc($commentData);
$comments[] = $commentrow;
echo '<h3>' . $row['post_title'] . '</h3>';
echo '<h5>' . $row['post_author'] . ', ' . $row['post_date'] . '</h5>';
echo '<p>' . $row['post_excerpt'] . '... read more</p>';
if($row['comment_count'] > 0) {
echo '<blockquote>';
echo '<b>Comments</b><br />';
foreach($comments as $comment) {
if($row['ID']==$comment['comment_post_ID']) {
$comment_excerpt = substr($comment['comment_content'],0,100);
echo '<br>' . $comment_excerpt . ' - <b>' . $comment['comment_author'] . '</b>, ' . $comment['comment_date'] . '<br>';
}
}
echo '</blockquote>';
}
}
I have two scripts below. The first script only searches one Column for a user-typed keyword, then it will display the results as a list and make BOLD the characters the user typed. That script works great.
The second script is something I modified to search multiple columns. It searches just fine. The problem is that I cannot get the BOLD (or make STRONG) if the searched value came from the other columns. How do I determine if the searched value came for Column 1, Column 2, Column 3, etc...? If the searched value came from column "DESCRIP" then I want to make the letter bold in the listed value.
First Script:
<?php
require_once("../config.php");
$keyword = '%'.$_POST['keyword'].'%';
$rootval = $_POST['rval'];
$sql = "SELECT `ID`,`MUNTERS_PN`,`DESCRIP`, `IMG_PATH`, `MANUF`, `MANUF_PN` FROM `electrical_parts` WHERE `MUNTERS_PN` LIKE (:keyword) ORDER BY `MUNTERS_PN` ASC LIMIT 0, 5";
$query = $db_qms->prepare($sql);
$query->bindParam(':keyword', $keyword, PDO::PARAM_STR);
$query->execute();
$list = $query->fetchAll();
foreach ($list as $rs) {
// put in bold the written text
$partnum = str_replace($_POST['keyword'], '<span style="font-weight:700;font-size:14px;">'.$_POST['keyword'].'</span>', $rs['MUNTERS_PN']);
// add new option
echo '<li class="set_part" data-val="' . $rs['ID'] . '"><img src="' . $rootval . '../parts/' . $rs['IMG_PATH'] . '" width="100px;" style="padding-right:15px;">'.$partnum.'<span style="font-style:italic;font-size:13px;padding-left:10px;">[' . $rs['MANUF'] . ': ' . $rs['MANUF_PN'] . '] <br/>' . $rs['DESCRIP'] . '</span></li>';
}
?>
Second Script:
<?php
require_once("../config.php");
$keyword = '%'.$_POST['keyword'].'%';
$rootval = $_POST['rval'];
$sql = "SELECT `ID`,`MUNTERS_PN`,`DESCRIP`, `IMG_PATH`, `MANUF`, `MANUF_PN` FROM `electrical_parts` WHERE (`MUNTERS_PN` LIKE (:keyword) OR `DESCRIP` LIKE (:keyword) OR `MANUF` LIKE (:keyword) OR `MANUF_PN` LIKE (:keyword) ) ORDER BY `MUNTERS_PN` ASC LIMIT 0, 5";
$query = $db_qms->prepare($sql);
$query->bindParam(':keyword', $keyword, PDO::PARAM_STR);
$query->execute();
$list = $query->fetchAll();
foreach ($list as $rs) {
/******* INSERT CODE TO DETERMINE WHICH COLUMN WAS QUERIED ******/
// put in bold the written text
$partnum = str_replace($_POST['keyword'], '<span style="font-weight:700;font-size:14px;">'.$_POST['keyword'].'</span>', $rs['MUNTERS_PN']);
$manuf = str_replace($_POST['keyword'], '<span style="font-weight:700;font-size:14px;">'.$_POST['keyword'].'</span>', $rs['MANUF']);
$manuf_pn = str_replace($_POST['keyword'], '<span style="font-weight:700;font-size:14px;">'.$_POST['keyword'].'</span>', $rs['MANUF_PN']);
$descrip = str_replace($_POST['keyword'], '<span style="font-weight:700;font-size:14px;">'.$_POST['keyword'].'</span>', $rs['DESCRIP']);
// add new option
echo '<li class="set_part" data-val="' . $rs['ID'] . '"><img src="' . $rootval . '../parts/' . $rs['IMG_PATH'] . '" width="100px;" style="padding-right:15px;">'.$partnum.'<span style="font-style:italic;font-size:13px;padding-left:10px;">[' . $rs['MANUF'] . ': ' . $rs['MANUF_PN'] . '] <br/>' . $rs['DESCRIP'] . '</span></li>';
}
?>
Be careful, in the echo in the second script, you use $rs['MANUF'], $rs['MANUF_PN'] and $rs['DESCRIP'] instead of $manuf, $manuf_pn and $descrip.
That is why the replacements don't appear in the output.
So you should use :
echo '<li class="set_part" data-val="' . $rs['ID'] . '"><img src="' . $rootval . '../parts/' . $rs['IMG_PATH'] . '" width="100px;" style="padding-right:15px;">'.$partnum.'<span style="font-style:italic;font-size:13px;padding-left:10px;">[' . $rs['MANUF'] . ': ' . $manuf_pn . '] <br/>' . $descrip . '</span></li>';
I have a form that uses a PHP for loop after it is submitted. The loop updates individual rows in the database one after the next based on the form data submitted. However, I've noticed that the loop stops working if there are more than 31 rows that need to be updated. It will update everything perfectly for the first 31 loops but then will not work after the 31st loop?
UPDATE: I've done some testing and it seems that the loop never finishes. It just refreshes the page in the browser instead of printing the results. What is causing this?
Is there a MYSQL query setting somewhere that is causing this?
Here is my loop's code:
for($i=1;$i<=$total_results2;$i++)
{
$strSQL = 'UPDATE timesheets_items SET ';
$strSQL .= 'time_1 = "' . convert_time($_POST['item_' . $i . '_time_1']) . '"';
$strSQL .= ', time_2 = "' . convert_time($_POST['item_' . $i . '_time_2']) . '"';
$strSQL .= ', time_3 = "' . convert_time($_POST['item_' . $i . '_time_3']) . '"';
$strSQL .= ', time_4 = "' . convert_time($_POST['item_' . $i . '_time_4']) . '"';
$strSQL .= ', time_5 = "' . convert_time($_POST['item_' . $i . '_time_5']) . '"';
$strSQL .= ', time_6 = "' . convert_time($_POST['item_' . $i . '_time_6']) . '"';
$strSQL .= ', time_7 = "' . convert_time($_POST['item_' . $i . '_time_7']) . '"';
$strSQL .= ', time_8 = "' . convert_time($_POST['item_' . $i . '_time_8']) . '"';
$strSQL .= ', time_9 = "' . convert_time($_POST['item_' . $i . '_time_9']) . '"';
$strSQL .= ', time_10 = "' . convert_time($_POST['item_' . $i . '_time_10']) . '"';
$strSQL .= ', time_11 = "' . convert_time($_POST['item_' . $i . '_time_11']) . '"';
$strSQL .= ', time_12 = "' . convert_time($_POST['item_' . $i . '_time_12']) . '"';
$strSQL .= ', time_13 = "' . convert_time($_POST['item_' . $i . '_time_13']) . '"';
$strSQL .= ', time_14 = "' . convert_time($_POST['item_' . $i . '_time_14']) . '"';
$strSQL .= ', time_total = "' . convert_time($_POST['item_' . $i . '_time_total']) . '"';
$strSQL .= ', ot_1 = "' . convert_time($_POST['item_' . $i . '_ot_1']) . '"';
$strSQL .= ', ot_2 = "' . convert_time($_POST['item_' . $i . '_ot_2']) . '"';
$strSQL .= ', ot_3 = "' . convert_time($_POST['item_' . $i . '_ot_3']) . '"';
$strSQL .= ', ot_4 = "' . convert_time($_POST['item_' . $i . '_ot_4']) .'"';
$strSQL .= ', ot_5 = "' . convert_time($_POST['item_' . $i . '_ot_5']) . '"';
$strSQL .= ', ot_6 = "' . convert_time($_POST['item_' . $i . '_ot_6']) . '"';
$strSQL .= ', ot_7 = "' . convert_time($_POST['item_' . $i . '_ot_7']) . '"';
$strSQL .= ', ot_8 = "' . convert_time($_POST['item_' . $i . '_ot_8']) . '"';
$strSQL .= ', ot_9 = "' . convert_time($_POST['item_' . $i . '_ot_9']) . '"';
$strSQL .= ', ot_10 = "' . convert_time($_POST['item_' . $i . '_ot_10']) . '"';
$strSQL .= ', ot_11 = "' . convert_time($_POST['item_' . $i . '_ot_11']) . '"';
$strSQL .= ', ot_12 = "' . convert_time($_POST['item_' . $i . '_ot_12']) . '"';
$strSQL .= ', ot_13 = "' . convert_time($_POST['item_' . $i . '_ot_13']) . '"';
$strSQL .= ', ot_14 = "' . convert_time($_POST['item_' . $i . '_ot_14']) . '"';
$strSQL .= ', ot_total = "' . convert_time($_POST['item_' . $i . '_ot_total']) . '"';
$strSQL .= 'WHERE week_start = "' . $week_start . '" AND employee_id = "' . $id . '" AND project_number = "' . $_POST['item_' . $i . '_project_number'] .'" AND task = "' . $_POST['item_' . $i . '_task'] .'"';
mysql_query($strSQL);
}
I have now solved the issue ! The problem was caused by my version of PHP (5.3) and the amount of input variables allowed by PHP on a form.
The problem ended up not being MySQL related at all. The bug found was limiting how many form variables were taken in by PHP thus not allowing MySQL to ever get to see those variables when it came time to run the repeated queries loop.
To resolve the issue, I had to update to PHP (5.4 or greater) and then set the "max_input_vars" setting to 3000. (The default setting only allows 1000.)
I hope this helps anyone who ever comes across this same problem.
So let's say I have 30 entries in my database, I select the first 7 to get on my first page like this:
$qryRandomGallery = "SELECT a.Titel, a.KW, a.KWKidsID, a.KWKidsBeschrijving, b.ScoreAfbeelding, c.GebruikersNaam
FROM tblKWKids AS A
LEFT JOIN tblScore AS b
ON a.ScoreID = b.ScoreID
LEFT JOIN tblUser as C
ON a.UserID = c.UserID
ORDER BY RAND()
LIMIT 6";
if ($stmtRandomGallery = mysqli_prepare($dbconn, $qryRandomGallery)) {
mysqli_stmt_execute($stmtRandomGallery);
mysqli_stmt_bind_result($stmtRandomGallery, $KWTitel, $KWURL, $KWID, $KWKiddyBeschrijving, $ScoreAfb, $USER);
mysqli_stmt_store_result($stmtRandomGallery);
}
$qryRandomGalleryBIG = "SELECT a.Titel, a.KW, a.KWKidsID, a.KWKidsBeschrijving, b.ScoreAfbeelding, c.GebruikersNaam
FROM tblKWKids AS A
LEFT JOIN tblScore AS b
ON a.ScoreID = b.ScoreID
LEFT JOIN tblUser as C
ON a.UserID = c.UserID
ORDER BY RAND()
LIMIT 1";
if ($stmtRandomGalleryBIG = mysqli_prepare($dbconn, $qryRandomGalleryBIG)) {
mysqli_stmt_execute($stmtRandomGalleryBIG);
mysqli_stmt_bind_result($stmtRandomGalleryBIG, $KWTitelB, $KWURLB, $KWIDB, $KWKiddyBeschrijvingB, $ScoreAfbB, $USERB);
mysqli_stmt_store_result($stmtRandomGalleryBIG);
}
and then this as my php
while(mysqli_stmt_fetch($stmtRandomGallery)){
$content .= '<div>';
$content .= '<a href="galerij.php?id=' . $KWID . '">';
$content .= '<img src="' . $KWURL . '" title="' . $KWTitel . '" alt="' . $KWTitel . '" class="image">';
$content .= '<h5>' . $KWTitel . ' door: ' . $USER . '</h5>';
$content .= '<p>' . $KWKiddyBeschrijving . '</p>';
$content .= '<img src="' . $ScoreAfb . '" title="Score" alt="Score" class="img">';
$content .= '</a>';
$content .= '</div>';
}
while(mysqli_stmt_fetch($stmtRandomGalleryBIG)){
$content .= '<h2>Uitgelicht werk van ' . $USERB . '</h2>';
$content .= '<a href="galerij.php?id=' . $KWIDB . '">';
$content .= '<img src="' . $KWURLB . '" title="' . $KWTitelB . '" alt="' . $KWTitelB . '" id="image">';
$content .= '<h3>' . $KWTitelB . ' door: ' . $USERB . '</h3>';
$content .= '<h4>' . $KWKiddyBeschrijvingB . '</h4>';
$content .= '<img src="' . $ScoreAfbB . '" title="Score" alt="Score" id="score">';
$content .= '</a>';
}
Now, how do I exclude the results from the first stmt to select another random image for my BIG image?
Simple: Take the IDs of your first query and stuff them into the second query as a not in:
SELECT ...
FROM yourtable
WHERE idField NOT IN (x,y,z,p,q,r)
This'll exclude them from second query's results.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I just got my last question answered but now I'm stuck again.. I'm using OpenCart and I want to change the style of my email you'll get when you register on my OpenCart webshop. But when I use add this for example, it just shows it in the email as normal text:
$message .= '<img src="logo.png" />' "\n";
When I searched it on Google, on every site it says that I have to use this:
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
I pasted it on a few places in my code but it never worked, it was still showing the HTML Tags as text in the email.
I will paste my code (from OpenCart) here and can somebody tell me then where I have to paste that code or just another way to use HTML in email via PHP?
<?php
class ModelAccountCustomer extends Model {
public function addCustomer($data) {
if (isset($data['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($data['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $data['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET store_id = '" . (int)$this->config->get('config_store_id') . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "', customer_group_id = '" . (int)$customer_group_id . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', status = '1', approved = '" . (int)!$customer_group_info['approval'] . "', date_added = NOW()");
$customer_id = $this->db->getLastId();
$this->db->query("INSERT INTO " . DB_PREFIX . "address SET customer_id = '" . (int)$customer_id . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', company = '" . $this->db->escape($data['company']) . "', company_id = '" . $this->db->escape($data['company_id']) . "', tax_id = '" . $this->db->escape($data['tax_id']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', city = '" . $this->db->escape($data['city']) . "', postcode = '" . $this->db->escape($data['postcode']) . "', country_id = '" . (int)$data['country_id'] . "', zone_id = '" . (int)$data['zone_id'] . "'");
$address_id = $this->db->getLastId();
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$customer_id . "'");
$this->language->load('mail/customer');
Here starts the part of the code what is going to be visible in the email itself.
<--From here-->
**$subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
$message = sprintf($this->language->get('text_welcome'), $this->config->get('config_name')) . "\n\n";
if (!$customer_group_info['approval']) {
$message .= $this->language->get('text_login') . "\n";
} else {
$message .= $this->language->get('text_approval') . "\n";
}
$message .= $this->url->link('account/login', '', 'SSL') . "\n\n";
$message .= $this->language->get('text_services') . "\n\n";
$message .= $this->language->get('text_thanks') . "\n";
$message .= $this->config->get('config_name');**
<--Till here-->
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($data['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_name'));
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
// Send to main admin email if new account email is enabled
if ($this->config->get('config_account_mail')) {
$message = $this->language->get('text_signup') . "\n\n";
$message .= $this->language->get('text_website') . ' ' . $this->config->get('config_name') . "\n";
$message .= $this->language->get('text_firstname') . ' ' . $data['firstname'] . "\n";
$message .= $this->language->get('text_lastname') . ' ' . $data['lastname'] . "\n";
$message .= $this->language->get('text_customer_group') . ' ' . $customer_group_info['name'] . "\n";
if ($data['company']) {
$message .= $this->language->get('text_company') . ' ' . $data['company'] . "\n";
}
$message .= $this->language->get('text_email') . ' ' . $data['email'] . "\n";
$message .= $this->language->get('text_telephone') . ' ' . $data['telephone'] . "\n";
$mail->setTo($this->config->get('config_email'));
$mail->setSubject(html_entity_decode($this->language->get('text_new_customer'), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
// Send to additional alert emails if new account email is enabled
$emails = explode(',', $this->config->get('config_alert_emails'));
foreach ($emails as $email) {
if (strlen($email) > 0 && preg_match('/^[^\#]+#.*\.[a-z]{2,6}$/i', $email)) {
$mail->setTo($email);
$mail->send();
}
}
}
}
public function editCustomer($data) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
public function editPassword($email, $password) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($password)))) . "' WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
}
public function editNewsletter($newsletter) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET newsletter = '" . (int)$newsletter . "' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
public function getCustomer($customer_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
return $query->row;
}
public function getCustomerByEmail($email) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
return $query->row;
}
public function getCustomerByToken($token) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE token = '" . $this->db->escape($token) . "' AND token != ''");
$this->db->query("UPDATE " . DB_PREFIX . "customer SET token = ''");
return $query->row;
}
public function getCustomers($data = array()) {
$sql = "SELECT *, CONCAT(c.firstname, ' ', c.lastname) AS name, cg.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT JOIN " . DB_PREFIX . "customer_group cg ON (c.customer_group_id = cg.customer_group_id) ";
$implode = array();
if (isset($data['filter_name']) && !is_null($data['filter_name'])) {
$implode[] = "LCASE(CONCAT(c.firstname, ' ', c.lastname)) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
}
if (isset($data['filter_email']) && !is_null($data['filter_email'])) {
$implode[] = "LCASE(c.email) = '" . $this->db->escape(utf8_strtolower($data['filter_email'])) . "'";
}
if (isset($data['filter_customer_group_id']) && !is_null($data['filter_customer_group_id'])) {
$implode[] = "cg.customer_group_id = '" . $this->db->escape($data['filter_customer_group_id']) . "'";
}
if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
$implode[] = "c.status = '" . (int)$data['filter_status'] . "'";
}
if (isset($data['filter_approved']) && !is_null($data['filter_approved'])) {
$implode[] = "c.approved = '" . (int)$data['filter_approved'] . "'";
}
if (isset($data['filter_ip']) && !is_null($data['filter_ip'])) {
$implode[] = "c.customer_id IN (SELECT customer_id FROM " . DB_PREFIX . "customer_ip WHERE ip = '" . $this->db->escape($data['filter_ip']) . "')";
}
if (isset($data['filter_date_added']) && !is_null($data['filter_date_added'])) {
$implode[] = "DATE(c.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
}
if ($implode) {
$sql .= " WHERE " . implode(" AND ", $implode);
}
$sort_data = array(
'name',
'c.email',
'customer_group',
'c.status',
'c.ip',
'c.date_added'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY name";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getTotalCustomersByEmail($email) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
return $query->row['total'];
}
public function getIps($customer_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_ip` WHERE customer_id = '" . (int)$customer_id . "'");
return $query->rows;
}
public function isBanIp($ip) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_ban_ip` WHERE ip = '" . $this->db->escape($ip) . "'");
return $query->num_rows;
}
}
?>
The one that reads this, thank you for your time!
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
Your setting it as text.
Try setting has HTML.
$mail->setHTML($message);