Hovercard无法使用PHP代码

时间:2015-07-24 20:02:33

标签: javascript php jquery

我正在尝试在我的网站上为我网站上注册的用户使用HoverCard。我如何设法使用PHP从数据库中获取数据并将其发送到我的js脚本?

PHP代码:User.php / UserManager.php

class User{
    private $id;
    private $Fullname;
    private $Email;
    private $Password;
function __construct() {

         $num= func_num_args();


         switch ($num){

             case 4:

                  $this->id=func_get_arg(0);
                  $this->Fullname=func_get_arg(1);
                  $this->Email=func_get_arg(2);
                  $this->Password=func_get_arg(3);
                  break;
}
}
 public function getId(){

        return $this->id;


    }
public function getFullname(){

        return $this->Fullname;


    }

     public function getEmail(){

        return $this->Email;


    }

     public function getPassword(){

        return $this->Password;


    }

}

require_once '../controleurs/User.php';
class UserManager{

    static private function ChekUserInscription($id){
    $user_select = mysql_query("SELECT * FROM users WHERE id='$id'",$dbc);
    while ($row=mysql_fetch_assoc($user_select)){
        $f=@new User($row['Id'],$row['Fullname'],$row['Email'],$row['Password']

               }
  return $f; 

}

JS代码:hovercard.js

    $(function() {
    $('#my-tooltip').tooltipster({
        interactive: true,
        content: 'Loading...',
        contentCloning: false,
        contentAsHTML: true,
        animation: 'fade',
        functionBefore: function(origin, continueTooltip) {

            continueTooltip();
            origin.tooltipster('content', 
            '<div class="hovercard"> \n\
            <div> \n\
            <div class="display-pic"> \n\
            <div class="cover-photo"> \n\
            <div class="display-pic-gradient"></div>\n\
            <img src="img/NY.jpg" style="width:370px;height:200px;"> </div>\n\
            <div class="profile-pic"><div class="pic"> \n\
            <span class="chat-img">\n\
            <a href="#"><img src="image/19068919.54b2108777ce0.png" alt="User Avatar" class="img-circle" style="width:98px;height:98px;"></a>\n\
            </span></div>\n\
            <div class="details"> <ul class="details-list"> \n\
            </div></div></div><div class="display-pic-gradient"></div>\n\
            <div class="title-container"> \n\
            <a href="#">Tamil Selvan</a> \n\
            <p class="other-info">    <?php echo $name ?>    </p></div>\n\
            <div class="info"><div class="info-inner"> <div class="interactions"> <a href="#" class="btn"><i class="fa fa-user-plus"></i> Add Friend</a> <a href="#" class="btn"><i class="fa fa-user-plus"></i> Add Friend</a> \n\
            <a href="#" class="btn">Follow</a> </div></div></div></div></div>');
        }
    });
});

之后

<?php 

                                $user=new userManager();
                                $id=$user->getId();
                                $name=$user->getFullname();
                                $password=$user->getPassword();
                                $email=$user->getEmail();

?>

我想让来自JS代码里面的PHP代码的$ name令牌出现在hovercard中,但是它无效!

0 个答案:

没有答案