tags:

views:

40

answers:

1

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
}elseif($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?

A: 
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.

pinkfloydx33
how can i work with this in my code?
Johnson
I updated the above to hopefully give you an idea where I'm going with it.
pinkfloydx33
ok and where do i select * from the users_msgs?
Johnson
Do you NEED to select *? If you need some other data from the table you'll need to make a separate call to it wherever it seems appropriate (I don't know how you are using it). If you had another column that had message text you couldn't put it in the distinct query because then you'd get a result for each row since they'd all be different.
pinkfloydx33
ok did you write uuid or is it just a typo? if no, then what for? And i need columns: msg and header, should i make another query? How can i do that, if i use $string in the while? Could you show me example?
Johnson
and i cant even select id from the first query with distrinct, so later i could just do WHERE id = ..
Johnson
And i just tried your query, with a while inside if($sWall>1).. Look let me update the question with new code + new explanation of what I wish to do, so i dont make you confused.
Johnson