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
    New Coder
    Join Date
    Oct 2008
    Posts
    38
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Macintosh PHP While() with jQuery? it doesn't show second record!

    Hello guys!

    My idea is to pull private messages to the user using PHP from MySQL, then when the user click on <div> element, then it should fadeIn() the message for him.

    Let's see it in action:

    PHP Code:
    <script type="text/javascript">
    $(document).ready(function(){
        
        
        $("#subj").click(function(){
            $("#msgBox").css('display', 'inline').fadeIn(3000);    
            });
        }
    });        
    </script>

    <?
    // PHP code!
    // query to get the messages!
    $SQL mysql_query("SELECT * FROM msg WHERE to_id = '".$userid."' AND `read` = \"0\"")or die(mysql_error()); 


    // loop and pull more msgs !
    while($row mysql_fetch_array($SQL)){
            
    // Only a function to get the username instead of user id! do not see it!
        
    $sender sender($row["from_id"],$row["to_id"] );
            
    // Out put format!
        
    echo 'From: '.$sender[0].' |,| And To '.$row["to_id"].' |,| subject! is:';
            
            
    // Subject here! look in it has span id of *SUBJ* !
        
    echo '<span id="subj"><font color="red">'.$row["subj"].'</font></span>';

            
    // The Private message!
        
    echo '<span id="msgBox" style="display:none;">'.$row["msg"].'</span>';

    }
    ?>
    This couldn't work!

    it only works with the *FIRST* record of private messages!
    But doesn't with the second message!


    Help would be appreciated!
    Last edited by samoi; 10-17-2009 at 06:14 AM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You need to use an Ajax call or reload the page.

  • #3
    New Coder
    Join Date
    Oct 2008
    Posts
    38
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    You need to use an Ajax call or reload the page.

    Can you please help me with it! I haven't ever deal with ajax call kind of thing!



  •  

    Posting Permissions

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