0

申し訳ありませんが、PHPでのコーディング方法は本当にわかりませんが、以下のコードを使用して画像(ボタン)からポップアップを作成する必要があります。それはまた、招待者ボックスを明らかにすることもできます...しかし、それは同じままである必要があります(Facebookの招待者ボックスではありません)

if(count($user_data)>0) {
    $user = get_users(array('fb_user_id'=>$user_data['id']));
    $invited_ids = $user[0]['invited_ids'];
    $invited_ids_tab = json_decode($invited_ids, true);
    $nb_invited_friends = count($invited_ids_tab);

    //page header
    echo '<img src="'.$user_data['picture'].'" style="width:36px; vertical-align:middle; margin-right:10px; margin-bottom:10px;">';
    echo '<b>Bienvenue '.$user_data['name'].'</b> (<a href="#" id="fb_box_fb_logout_btn">Déconnection</a>) - ';

    if(count($user)>0) echo 'Nombre d\'amis invité <b>'.$nb_invited_friends.'</b>';
    else echo 'You didn\'t invite any friend yet.';

    echo ' - <a href="./content.php">Voir les coupons disponible </a>';

    echo '<hr><br>';

    //display inviter
    $inviter = displayInviter();
    echo $inviter;
}
else {
    echo '<a href="#" id="fb_box_fb_login_btn" class="facebook16">Connect with Facebook</a>, Invite your friends and Unlock your reward !';
}

?

ポップアップに欲しいのは

$ inviter = displayInviter(); エコー$inviter;

ありがとうございました

4

2 に答える 2

2

PHP can't make popups by itself, because once the page renders, PHP shuts down, so to speak. What you'll need is Javascript, the easiest way would be to use jQuery's ajax method to call the PHP page with the code you provided, load the code output into a hidden div element and then make it pop up using the fadeIn method, for example.

Or, if you want to keep the code within the same page, do the same as above, only instead of using the load() function, just echo the popup content into the hidden div.

Simple example:

HTML/PHP

<div id="popup" style="display: none;"><?php echo displayInviter(); ?></div>

JS function

$('#popup').fadeIn();
于 2012-05-21T19:43:10.753 に答える
0

try:

echo '<a href="javascript:alert('.$inviter.')">';
于 2012-05-21T19:45:40.443 に答える