Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    134
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Privare Messaging Code help

    Hi Guys,

    what i'm trying to do here is turn the word "inbox" red if the messages have all been read and blue if there is messages in there that are unread my code is:

    PHP Code:
    <?php
         
    // Get the users details from mysql...//////////////////////////////////////////////
         
    $query_1 "SELECT * FROM `membership` WHERE `username`='$member'";
         
    $result_1 mysql_query($query_1) or die (mysql_error());
         
    $row mysql_fetch_array($result_1);
         
         
    $id $row['id'];
         
    $username $row['username'];
         
    $email $row['email'];
         
    $country $row['country'];
         
    $avatar $row['avatar'];
         
         
    // check if the user has messages in there inbox.../////////////////////////////////
         
    $query_msg "SELECT * FROM `pms` WHERE `reciever_id`='$id'";
         
    $result_msg mysql_query($query_msg) or die (mysql_error());
         
    $rows mysql_fetch_array($result_msg) or die (mysql_error());
         
         
    $how_many mysql_num_rows($result_msg);
         
         
    $read $rows['read_flag'];
         
         if (
    mysql_num_rows($result_msg) > 0) {
         
            echo 
    '<a href="inbox.php"><font color="red">Inbox</font></a>&nbsp;&nbsp;|&nbsp;';
            
         } elseif (
    $read == 'N') {
         
            echo 
    '<a href="inbox.php"><font color="blue">Inbox</font></a>&nbsp;&nbsp;|&nbsp;';
         
         } else {
         
            echo 
    '<a href="inbox.php">Inbox</a>&nbsp;&nbsp;|&nbsp;';     
         
         }
    ?>
    i know i need to loop all the messaages to see if they are read or not but not sure how to go about it here lol

    any help/advice would be appreciatede

    Cheers

    Graham

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Instead of:
    PHP Code:
    $rows mysql_fetch_array($result_msg) or die (mysql_error());
         
         
    $how_many mysql_num_rows($result_msg);
         
         
    $read $rows['read_flag'];
         
         if (
    mysql_num_rows($result_msg) > 0) {
         
            echo 
    '<a href="inbox.php"><font color="red">Inbox</font></a>&nbsp;&nbsp;|&nbsp;';
            
         } elseif (
    $read == 'N') {
         
            echo 
    '<a href="inbox.php"><font color="blue">Inbox</font></a>&nbsp;&nbsp;|&nbsp;';
         
         } else {
         
            echo 
    '<a href="inbox.php">Inbox</a>&nbsp;&nbsp;|&nbsp;';     
         
         } 
    try
    PHP Code:
    $how_many mysql_num_rows($result_msg);

    $box_color "red";

    while (
    $row mysql_fetch_assoc($result_msg) or die (mysql_error())
    {
        if ( 
    $row['read_flag'] == 'N')
        {
            
    $box_color "blue";
        }
    }
         
    echo 
    '<a href="inbox.php"><font color="' $box_color '">Inbox</font></a>&nbsp;&nbsp;|&nbsp;'

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    134
    Thanks
    12
    Thanked 0 Times in 0 Posts
    That works perferct ,mate thanks for that

    Graham


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •