通知php脚本

Greetings I have been stuck trying to put together a notification script that informs a customer when an item they want has been uploaded to the database. so far i have managed to fetch and match what the customer wants with what's on the database the problem now is notifying the customer that the item is available via email. This is the code i've managed to put together

<?php
require 'dbh.php';
require 'dbu.php';
require 'phpmailer/PHPMailer/PHPMailerAutoload.php';


        $sql="SELECT product_name,product_price,userID,location,category,first_name FROM notification";
        $result= mysqli_query($con, $sql);
        $queryResult=mysqli_num_rows($result);
        echo "".$queryResult."<hr>";
        if ($queryResult>0) {
            while ($row=mysqli_fetch_assoc($result)) {
                $name=$row['product_name'];
                $price=$row['product_price'];
                $location=$row['location'];
                $category=$row['category'];
                $email=$row['userID'];
                $first_name=$row['first_name'];
                $product_details=array($name,$price);
                $final=implode("",$product_details);
                echo "<br>".$final."<hr>";                                              
            $sql2="SELECT id,product_name,product_price,location,category FROM products";
            $result2= mysqli_query($con,$sql2);
            $queryResult2=mysqli_num_rows($result);
             if ($queryResult2>0) {
                while ($res=mysqli_fetch_assoc($result2)) {
                $product_details2= array($res['product_name'],$res['product_price']);
                        $final2=implode('', $product_details2);
                        $results=similar_text($final, $final2,$perc);

                        if ($perc>=60) {

                            //echo "<br>Product ID:".$res['id']." Similar by ".$perc."%<br>";
                            echo "".ceil($perc)."%
                                 ".$res['id']."
                                 ".$res['product_name']."
                                 ".$res['product_price']."
                                 ".$res['location']." ".$email."<br>";

                            $mail = new PHPMailer;
                            $mail->isSMTP();                                   // Set mailer to use SMTP
                            $mail->Host = '';                    // Specify main and backup SMTP servers
                            $mail->SMTPAuth = true;                            // Enable SMTP authentication
                            $mail->Username = '';          // SMTP username
                            $mail->Password = ''; // SMTP password
                            $mail->SMTPSecure = 'ssl';                         // Enable TLS encryption, `ssl` also accepted
                            $mail->Port = 465;                                 // TCP port to connect to

                            $mail->setFrom('notify@example.COM', 'Notification Email');
                            $mail->addReplyTo('notify@example.com', 'Notification Email');
                            $mail->addAddress($email);   // Add a recipient
                            //$mail->addCC('cc@example.com');
                            //$mail->addBCC('bcc@example.com');

                            $mail->isHTML(true);  // Set email format to HTML

                            $bodyContent = 'Hello '.$first_name.',

                                    An Item that matches what you requested is available click the link below to 
                                    check it out
                                    http://localhost/notify.php?email='.$email.'&hash=';

                            $mail->Subject = 'Item Notification (example.com)';
                            $mail->Body    = $bodyContent;




                }/*else{
                    echo "<br>not a close match<br>";
                }*/
             }
            }
        }}