对同一字段名称的多个记录进行处理

时间:2019-03-10 14:42:57

标签: php mysql

我有一个活动预订Wordpress网站,预订后人们会在该网站上收到有关其预订详细信息的电子邮件。这些详细信息存储在MYSQL行中。但是,如果该人有一个以上的预订,或具有多个不同座位的记录。然后,每当他尝试获取第二次预订的确认电子邮件时,都只会从数据库中获取第一条记录,而不是第二条记录。有没有一种方法可以同时收到两封预订的两封电子邮件。

这是我的代码:

<?php
    date_default_timezone_set('Asia/Dhaka');

    /*---------------DB connectivity start--------------------------------*/
    $host="host";
    $user="user";
$password="password";
$db="db";

mysql_connect($host,$user,$password);
mysql_select_db($db);

if(isset($_POST['email'])){

    $email1=$_POST['email'];
    //echo "Email id ";
   // echo $email1;
    $query="select * from wp_bap_orders where email='".$email1."' ";

    $result=mysql_query($query);

    $count=mysql_num_rows($result);    
    if($result->num_rows > 0)
    {
         while ($rows=mysqli_fetch_row($result)){
    $rows=mysql_fetch_array($result);
    $orderid = $rows['order_id'];
    $name1  =  $rows['first_name'];
    $name2  =  $rows['last_name'];
    $name3 = $name1 . " " . $name2;
    $email2  =  $rows['email'];
    $phone  =  $rows['phone'];
    $date  =  $rows['date'];
    $code  =  $rows['code'];
    $places  =  $rows['places'];
    //collect seat numbers
    $seatnumbersstr = '';
        foreach(unserialize($rows['places']) as $placearr){
            $seatnumbersstr=$seatnumbersstr.','.$placearr['place_name'];
        }
    $price  =  $rows['total_price'];
    $scheme_id  =  $rows['scheme_id'];
    $event_id  =  $rows['event_id'];
    $event  =  $rows['event'];
    $payment_type  =  $rows['payment_type'];
    //echo $scheme_id ;
    $qry1="select * from wp_bap_schemes where scheme_id='$scheme_id '";
         $result1=mysql_query($qry1);
            $count1=mysql_num_rows($result1); 
            if($count1==1)
                {
                $rows1=mysql_fetch_array($result1);
                $eventname =  $rows1['name'];//FETCHING EVENT NAME
                $eventdesc =  $rows1['description'];//FETCHING EVENT NAME
                }

    //echo $eventname;
    //echo " was found";



$message        = "
<html>
<body>
<center>
  <p align='center'>
  <font face='Verdana'><u><b><font size='4' color='#800000'>
  Booking confirmation mail</font></b></u></font>
  </p>

 <table border='0' cellspacing='1' width='92%' id='AutoNumber10' class='simpletext'>
 <tr>
    <td align='right'> <strong> Name :</strong></td>
    <td >&nbsp;</td>
    <td >". $name3."</td>
  </tr>
  <tr>
    <td align='right'> <strong>Email :</strong></td>
    <td >&nbsp;</td>
    <td >". $email2 ."</td>
  </tr>
  <tr>
    <td align='right'> <strong>Phone No :</strong></td>
    <td >&nbsp;</td>
    <td >". $phone ."</td>
  </tr>
   <tr>
    <td align='right'> <strong>Seat Number :</strong></td>
    <td >&nbsp;</td>
    <td >". $seatnumbersstr ."</td>
  </tr>
     <tr>
    <td align='right'> <strong>Event Booked :</strong></td>
    <td >&nbsp;</td>
    <td >". $eventname ."</td>
             <tr>
    <td align='right'> <strong>Show :</strong></td>
    <td >&nbsp;</td>
    <td >". $eventdesc."</td>
  </tr>
  </tr>
       <tr>
    <td align='right'> <strong>Amount :</strong></td>
    <td >&nbsp;</td>
    <td >". $price."</td>
  </tr>
   <tr>
    <td align='right'> <strong>Transitional ID :</strong></td>
    <td >&nbsp;</td>
    <td >". $code."</td>
  </tr>
</table>   
<h3 align='left'>Dear ". $name3 . ",</h3>
<p align='left'>Thank you for your booking with nokta.</p>          
</body>
</html>";
         }   
//$to="$email1";
    $to="admin@onesolution.co.in";
$subject = "Booking Confirmation email";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "From: info@noktaarts.com" . "\r\n" .
"CC: admin@onesolution.click";
mail($to,$subject,$message,$headers);
        echo '<script> alert("We Have Send Your Booking Ticket To Your Email Address. Please Ckeck Your Email."); window.location="index.php"; </script>';
     // print "<script>alert('We Have Send Your Booking Ticket To Your Email Address.</br>Please Ckeck Your Email.'); </script>";
//echo "You Have Received Your Booked Ticket Vai Email.</br> Please Check Your Email."; 

}



else
{
    echo"Not found";
}
}
?>

0 个答案:

没有答案