I just want to send multiple email to the recipients using mail() when i update the order status to notify the customers. (Im using my own email as testing, and each of the order from 1 to 10 is my email.)
So im suppose to receieved more than one email to myself..
But when i did it, i receieved only one email and inside that email at the "to" section, its display my email 10 times !! (to ahmadxxx#hotmail.com, ahmadxxx#hotmail.com, ahmadxxx#hotmail.com ... )
This is my form.
<form action="results-action" method="post" enctype="multipart/form-data">
<fieldset>
<table id ="table_id" class="display">
<thead>
<tr><td><h2>Pending Order</h2></td></tr>
<tr>
<th scope="col">Order ID</th>
<th scope="col">Order Number</th>
<th scope="col">Name</th>
<th scope="col">Address</th>
<th scope="col">Payment Method</th>
<th scope="col">Order Date</th>
<th scope="col">Product Name</th>
<th scope="col">Produt Quantity</th>
<th scope="col">Price</th>
<th scope="col">Order status</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><input type="text" value='<?=$row['virtuemart_order_id']?>' name="orderid" id="virtuemart_order_id"></td>
<td><?=$row['order_number']?></td>
<td><?=$row['first_name']?></td>
<td><?=$row['address_1']?></td>
<td><?=$row['payment_element']?></td>
<td><?=$row['created_on']?></td>
<td><?=$row['order_item_name']?></td>
<td><?=$row['product_quantity']?></td>
<td><?=$row['product_final_price'] ?></td>
<td><select name='change[<?=$row['virtuemart_order_id']?>]'>
<option value='C'> Confirmed</option>
<option value='X'> Cancelled</option></select></td>
</tr>
<?php
}
?>
</tbody>
</table>
</fieldset>
<fieldset>
<table>
<tr>
<td><input type="submit" value="Update status" name="update status"> </td>
</tr>
</table>
</fieldset>
</form>
This is my codes.
<?php
//filtering confirmed orders
function confirmed($v){return($v =='C');}
// pick the rows in your form table which have been set as confirmed, and use the keys
$id = implode(',', array_keys(array_filter($_POST['change'],'confirmed')));
// build SQL statement mail
$query3 = "SELECT * from ruj3d_virtuemart_order_userinfos where virtuemart_order_id IN (".$id.")";
// execute SQL statement
$result3 = mysqli_query($link, $query3) or die(mysqli_error($link));
while($row3 = mysqli_fetch_array($result3)){
$addresses[]=$row3['email'];
}
$to = implode(", ",$addresses);
$subject = "Order confirmed by Home and decor";
// message
$message = '
<html>
<body>
<table width="500" height="215" border="0">
<tr>
<th width="238" height="211" scope="col"><h1 align="left">Order # 1234</h1></p></th>
<th width="10" scope="col"></th>
<th width="243" scope="col"><p><img src="file:///D|/Programs/xampp/htdocs/images/sitelogo.PNG" width="224" height="68" align="right"></p></th>
</tr>
</table>
<table width="500" height="215" border="0">
<tr>
<th width="181" height="211" scope="col"><p align="left">Ship To:</p>
<p align="left">Customer name</p>
<p align="left">Blk 123</p>
<p align="left">Singapore, 123123</p></th>
<th width="80" scope="col"></th>
<th width="40" scope="col"></th>
<th width="181" scope="col"><p align="left"></p>
<p align="right">Bill To:</p>
<p align="right">Customer name</p>
<p align="right">Blk 123</p>
<p align="right">Singapore, 123123</p>
</th>
</tr>
</table>
<table width="500" height="94" border="0">
<tr>
<th height="43" scope="col"><div align="left">Order Date:</div></th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"><div align="right">Shipping Method:</div></th>
</tr>
<tr>
<th width="126" height="43" scope="col"><div align="left">1/11/13</div></th>
<th width="433" scope="col"> </th>
<th width="103" scope="col"> </th>
<th width="156" scope="col"><div align="right">BEAST!</div></th>
</tr>
</table>
<table width="500" height="88" border="1">
<tr>
<th width="48" scope="col">Item</th>
<th width="264" scope="col">Product Name</th>
<th width="68" scope="col">Quantity</th>
<th width="92" scope="col">Price</th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr>
<table width="500" height="227" border="0">
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Subtotal:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Tax:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Shipping:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Discount:</th>
<th scope="col"> </th>
</tr>
<tr>
<th width="40" height="43" scope="col"> </th>
<th width="278" scope="col"> </th>
<th width="68" scope="col">Grand Total:</th>
<th width="96" scope="col"> </th>
</tr>
</table>
<p align="right"> </p>
</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";
mail($to, $subject, $message, $headers);
?>
You need to move the code that composes and sends the mail inside the
while ($row3 = mysqli_fetch_array($result3)) {
...
}
loop, instead of making an array of all the addresses.
Related
I am trying to test out having multiple tables with various types of rows displayed on the webpage.
I am then using CSS Columns property to break the content in 4 columns.
My problem when the column finish; it continues the content on the next column. The tables I have can have multiple rows some have 10, some have 5 etc...
What I wanted to do is get page look a bit neater. If you see the picture I have attached below - I have some tables going to the next column.
What is the best practice or how to make this webpage look like a nice grid?
Here is how it looks
Here is the code:
<div class="row test">
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Bootstrap Stles -->
<script src="bootstrap-3.4.1/js/bootstrap.js"></script>
<script src="bootstrap-3.4.1/js/bootstrap.min.js"></script>
<style>
.navbar{
background-color: #EB4646;
border-radius: 0px;
color: white;
padding: 0.2%;
}
.test {
-webkit-column-count: 5;
-moz-column-count: 5;
column-count: 5;
</style>
Edit Answer
How it looks again
I have a delete button in my site that deletes a row in a table.
After the row is deleted, the user is redirect to another page.
Is it possible to display the deleted row values in the redirected page?
thank you!
<table class="table table-striped b-t b-light">
<thead>
<tr>
<th style="text-align: center">User Name</th>
<th style="text-align: center">User Last Name</th>
<th style="text-align: center">Email</th>
<th style="text-align: center">Password</th>
<th style="text-align: center">User Type</th>
<th style="text-align: center">Edit</th>
<th style="text-align: center">Delete</th>
</tr>
</thead>
<?php foreach ($ulistq as $urule) : ?>
<tbody>
<th style="text-align: center"><?= $urule['u_name'] ?></th>
<th style="text-align: center"><?= $urule['u_lastname'] ?></th>
<th style="text-align: center"><?= $urule['u_email'] ?></th>
<th style="text-align: center"><?= $urule['u_password'] ?></th>
<th style="text-align: center"><?= $urule['u_rule'] ?></th>
<td style="text-align: center"> Edit </td>
<td style="text-align: center"> Delete </td>
</tbody>
<?php endforeach; ?>
</table>
You can consider the option of adding the values to the redirect URL and extract them in the redirected page.
So instead of this redirect:
redirect to www.example.com/afterdelete
You can do
redirect to www.example.com/afterdelete?value1=1&value2=2
This option can be done both in the server side, as well as the client side.
You will need your afterDelete page to extract these values and to display them
I'm working on a php/mysql application and need to make the output of one column, one row an html link to another html page. Have not been able to find any relavant information. The "" needs to be the link. Thanks for any help.
<table id="display" style="width:800px;">
<tr>
<th width="40">ID</th>
<th width="70">Last</th>
<th width="70">First</th>
<th width="10">Middle</th>
<th width="70">Birth</th>
<th width="70">Death</th>
<th width="170">Notes</th>
<th width="100">Cemetery</th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td style='text-align:center;'><?=$objResult["id"];?></td>
<td style='text-align:center;'><?=$objResult["last"];?></td>
<td style='text-align:center;'><?=$objResult["first"];?></td>
<td style='text-align:center;'><?=$objResult["middle"];?></td>
<td style='text-align:center;'><?=$objResult["birth"];?></td>
<td style='text-align:center;'><?=$objResult["death"];?></td>
<td><?=$objResult["notes"];?></td>
<td style='text-align:center;'><?=$objResult["cemetery"];?></td>
</tr>
<?
}
?>
</table>
I'm having some issues getting all the data I need from two specific html tables. Tables at the bottom of this post.
The code above states html table id "table1". I also need to grab values from a table called "table2" in the exact same format. I have tried this code and can extract the td values but not the few values that are within the span specifiers within the td. I've tried multiple ways to do this but I'm just not getting it. My code looks something like:
$dom = file_get_html("internets.html);
//not sure how to specify the table exactly!? because this code didn't work.
//$tds = $dom->find('table[id=table1]',0)->find('tr');
foreach($dom->find('tr') as $key => $tr)
{
$td = $tr->find('td');
echo $td[0]->innertext . "</br>";
}
Any assistance much appreciated. I have done some searching here and also used the simple php dom manual.
Here is the format of a table:
<table id="table1">
<tbody>
<tr>
<th width="48%" scope="row">
Prev Close:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Open:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Bid:
</th>
<td class="yfnc_tabledata1">
<span id="yfs_b00_pgo.ax">
0.0180
</span>
</td>
</tr>
<tr>
<th width="48%" scope="row"></th>
<td class="yfnc_tabledata1"></td>
</tr>
<tr>
<th width="48%" scope="row">
1y Target Est:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="48%" scope="row">
Beta:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="54%" scope="row">
Next Earnings Date:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
</tbody>
</table>
<?php
$html=<<<XHTML
<table id="table1">
<tbody>
<tr>
<th width="48%" scope="row">
Prev Close:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Open:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Bid:
</th>
<td class="yfnc_tabledata1">
<span id="yfs_b00_pgo.ax">
0.0180
</span>
</td>
</tr>
<tr>
<th width="48%" scope="row"></th>
<td class="yfnc_tabledata1"></td>
</tr>
<tr>
<th width="48%" scope="row">
1y Target Est:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="48%" scope="row">
Beta:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="54%" scope="row">
Next Earnings Date:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
</tbody>
</table>
XHTML;
$dom = new DOMDocument;
$dom->loadHTML($html);
$xp = new DOMXPath($dom);
foreach ($xp->query("/*//table[#id='table1'//*/td") as $i=>$node) {
echo $node->nodeValue;
}
?>
i just want to send the order content fetching the result in my database.
But when i echo it, it displays it on my php page. i dont want it.
I want the content to only appear in the email when the user receive it.
This is my code.
while($row3 = mysqli_fetch_array($result3)){
$addresses=$row3['email'];
$to = $addresses;
$subject = "Order confirmed by Home and decor";
// message
$message = '
<html>
<body>
<table width="500" height="215" border="0">
<tr>
<th width="238" height="211" scope="col"><h1 align="left">Order # 1234</h1></p></th>
<th width="10" scope="col"></th>
<th width="243" scope="col"><p><img src="file:///D|/Programs/xampp/htdocs/images/sitelogo.PNG" width="224" height="68" align="right"></p></th>
</tr>
</table>
<table width="500" height="215" border="0">
<tr>
<th width="181" height="211" scope="col"><p align="left">Ship To:</p>
<p align="left"><?=$row3['first_name']?></p>
<p align="left"><?=$row3['address_1']?></p>
<p align="left"><?=$row3['city']?></p></th>
<th width="80" scope="col"></th>
<th width="40" scope="col"></th>
<th width="181" scope="col"><p align="left"></p>
<p align="right">Bill To:</p>
<p align="right"><?=$row3['first_name']?></p>
<p align="right"><?=$row3['address_1']?></p>
<p align="right"><?=$row3['city']?></p>
</th>
</tr>
</table>
<table width="500" height="94" border="0">
<tr>
<th height="43" scope="col"><div align="left">Order Date:</div></th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"><div align="right">Shipping Method:</div></th>
</tr>
<tr>
<th width="126" height="43" scope="col"><div align="left">1/11/13</div></th>
<th width="433" scope="col"> </th>
<th width="103" scope="col"> </th>
<th width="156" scope="col"><div align="right">BEAST!</div></th>
</tr>
</table>
<table width="500" height="88" border="1">
<tr>
<th width="48" scope="col">Item</th>
<th width="264" scope="col">Product Name</th>
<th width="68" scope="col">Quantity</th>
<th width="92" scope="col">Price</th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr>
<table width="500" height="227" border="0">
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Subtotal:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Tax:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Shipping:</th>
<th scope="col"> </th>
</tr>
<tr>
<th height="43" scope="col"> </th>
<th scope="col"> </th>
<th scope="col">Discount:</th>
<th scope="col"> </th>
</tr>
<tr>
<th width="40" height="43" scope="col"> </th>
<th width="278" scope="col"> </th>
<th width="68" scope="col">Grand Total:</th>
<th width="96" scope="col"> </th>
</tr>
</table>
<p align="right"> </p>
</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";
$headers .= 'From: Order reminder <lol#gmail.com>' . "\r\n";
mail($to, $subject, $message, $headers);
}
Echo is when you want to call something out right. I dont want it to echo, i just want to make the content appear in the email without echoing it.
Don't echo your variables, concatenate them into the string. i.e.
$message = "Some text ".$foo." some more text';
Not:
$message = "Some text <?=$foo ?> some more text';
Check out this PHP Documentation for Turn on output buffering.
http://php.net/manual/en/function.ob-start.php
Thanks
what are the sally wrong shorttag doing right in the middle of your message content.
<?= ?>
see this post for more information about shorttags
I'd just replace all those things from
<?php
$message '...
<p align="left"><?=$row3['first_name']?></p>
to
<?php
$message '...
<p align="left">'.$row3['first_name'].'</p>
You could use Heredoc syntax for this:
$message =<<<EOM
<html>
<body>
...
<table width="500" height="215" border="0">
<tr>
<th width="181" height="211" scope="col"><p align="left">Ship To:</p>
<p align="left">{$row3['first_name']}</p>
<p align="left">{$row3['address_1']}</p>
<p align="left">{$row3['city']}</p></th>
...
EOM;
It's recommended to apply htmlspecialchars() on $row3 first though:
$row3 = array_map('htmlspecialchars', $row3);
This assumes you will not use $row3 later in your code