开发者

PHP: show two times

开发者 https://www.devze.com 2023-01-22 23:17 出处:网络
I have a table called users_msgs with these columns: id | uID | nData and it has these rows: 1 | 2 | 20 2 | 2 | 20

I have a table called users_msgs with these columns:

id | uID | nData

and it has these rows:

1 | 2 | 20
2 | 2 | 20
3 | 2 | 20
4 | 2 | 20
5 | 2 | 25
6 | 2 | 25
7 | 2 | 25
8 | 2 | 25

uID is userid. So user 2 has written in a nDataid 20 four times, the same he did in nDataid 25.

I want to make so you only get one popup per same nData. So by these rows i would get 2 popups.

Right now i get only 1 popup for everything, and not per same nData. But that may be the way I SELECT:

<?php
$string = mysql_query("SELECT * FROM users_msgs 
            WHERE uID = '$USER' 
                AND type = 'wallComment'
            ")or die(mysql_error());
$get = mysql_fetch_array($string);
$sWall = mysql_num_rows($string);
    if($sWall>1){
?>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
        jGrowlTheme('wallPop', 'mono', 'Wall', 'You have <?php echo $sWall; ?> answers in id <?php echo $get["nData"]; ?>', 'images/wall.png', 10000);
        });
    </script>
<?php
}el开发者_运维技巧seif($sWall==1){ 
?>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
        jGrowlTheme('wallPop', 'mono', 'Wall', 'You have one new answer in id <?php echo $c; ?>', 'images/wall.png', 10000);
        });
    </script>
<?php } ?>

How can I solve this, so there comes two popups with "You have xx answers in id nData" when you have the rows as above?


select distinct uuid, ndata from users_msgs where uID = '$USER' and type = 'wallComment'

would give you two rows returned (one for each ndata for the user = $user).

I don't follow what exactly you're trying to do, so lets just simplify it a bit and maybe you will get it:

<?php
$string = mysql_query("SELECT distinct uuid, ndata FROM users_msgs 
            WHERE uID = '$USER' 
                AND type = 'wallComment'
            ")or die(mysql_error());
?>
<script language="javascript" type="text/javascript">
    $(document).ready(function(){  
        <?
         while ($sWall = mysql_fetch_assoc($string)) {
              echo 'alert("You have a message for ' . $sWall['ndata'] . '!")';
         }
        ?>        
    });
</script>

Would write an alert statement to the ready() function for each distinct ndata id for that user. The message would simply say "You have a message for NDATA#!" (replace ndata# with the value from the table)

Like I said, I'm a little confused as to what exactly you are doing, but hopefully this helps you out a bit.

0

精彩评论

暂无评论...
验证码 换一张
取 消