在关闭php标签并处理html标签内的php数据后,不能附加其余的字符串

时间:2018-04-27 07:29:33

标签: php html sql

我正在尝试向用户发送邮件,其中输出的病人姓名和医院名称已超链接到其位置(存在于数据库内)。消息体变量仅占用字符串医院名称,并且不会附加超链接到其在地图上的位置的医院的名称。请帮忙。提前致谢

    //Take contents of the search box
if($name=file_get_contents('file.txt')) {   //create a temp file in bloodonation and take the name from there,then delete the temp file
    $multiple= explode(',',$name);
    $firstname = $multiple[0]; // firstname                                                                                                   
    $fathername = $multiple[1]; // fathername
    $lastname = $multiple[2]; // lastname    
    unlink('file.txt'); 
    $query ="SELECT email
        FROM personprofile
        WHERE   firstname= '$firstname' AND lastname= '$lastname' AND fathername= '$fathername'";
        $fetchemail=  mysqli_query($link,$query);
        $process=mysqli_fetch_assoc($fetchemail);
        //mail function parameters, send two sets of messages depending on blood/organ donation
        // create a new paitent with the city beirut and check the mail results
        $to=$process['email'];
        $header= "Blood is urgently needed";
        $phquery="SELECT personprofile.firstname,personprofile.lastname,personprofile.fathername,hospital.hospitalname,hospital.geolocation 
        FROM personprofile,hospital,areaname 
        WHERE areaname.id= hospital.area AND personprofile.hospitaladmission= hospital.id AND areaname.area='$city'";
        $fetchospitalperson=  mysqli_query($link,$phquery);
        $processtable=mysqli_fetch_assoc($fetchospitalperson);
        $messagebody= "Patient Name: ".$processtable['firstname']." ".$processtable['fathername']." ".$processtable['lastname']."  "."Hospital Name:" ?>
        <html><body>
        <a href="<?php $processtable['geolocation']?>" >
        <?php " ".$processtable['hospitalname'];?>
        </a></body></html> 
        <?php //Name of the person that needs the blood transfusion along with hospital he is staying at,hyperlinked to its location
        $message= "Dear"." ".$firstname." ".$lastname.",".PHP_EOL .$messagebody; 
    if(isset($sendtoperson)){   
        if(mail($to,$header,$message)){
            echo "Sent";
        }
        else{ echo "Not sent";}
    }   
}

1 个答案:

答案 0 :(得分:0)

<?php
    $messagebodyA = "Patient Name: ".$processtable['firstname']." ";
    $messagebodyA .= $processtable['fathername']." ";
    $messagebodyA .= $processtable['lastname']." ";
    $messagebodyA .= "Hospital Name: ".$processtable['hospitalname'];

    $messagebody = "<html><body>";
    $messagebody .= '<a href="' .$processtable['geolocation']. '">'; // Note single quotes to allow double quotes in html tag
    $messagebody .= $processtable['hospitalname'];
    $messagebody .= "</a><br><br>";
    $messagebody .= "Dear ".$firstname." ".$lastname.",<br><br>".$messagebodyA;
    $messagebody .= "</body></html>";


    $message = $messagebody; // to be compliant with the rest of the code
?>