RaythMistwalker Posted January 5, 2010 Share Posted January 5, 2010 //check Messages $qry2="SELECT * FROM messages WHERE to_id='$id'"; $result2=mysql_query($qry2) or trigger_error('Query error! Query: <pre>'.$qry2.'</pre>Reason: ' . mysql_error()); $num2=mysql_numrows($result2); mysql_close(); //Check for Unread Messages $unread=0; $a=0; while ($a < $num2) { $msg=mysql_result($result2,$a,"viewed"); if ($msg < 1) { ++$unread; } ++$a; } This is my current working code to check if a user has unread messages and if they do then the inbox link is bold. Is there a way to make php send a pop up with just an ok button which closes the popup to alert the user they have unread messages? Quote Link to comment Share on other sites More sharing options...
aeroswat Posted January 5, 2010 Share Posted January 5, 2010 You could make a hidden div in the middle of the page that has the information that you need to hold in it and then make the div appear if they have unread messages until they press ok. Quote Link to comment Share on other sites More sharing options...
RaythMistwalker Posted January 5, 2010 Author Share Posted January 5, 2010 sorry i don't understand what you mean by this. Quote Link to comment Share on other sites More sharing options...
aeroswat Posted January 5, 2010 Share Posted January 5, 2010 sorry i don't understand what you mean by this. 1. Page Loads 2. Div is created with a hidden display. Div contains only a message (You have unread messages) and a button (possibly an image that acts as a button) 3. Php checks database to see if there are unread messages 4. If php finds unread messages then use javascript to set the div's display to visible 5. If user clicks the button the image goes away 6. Understanding achieved Quote Link to comment Share on other sites More sharing options...
ChaosKnight Posted January 5, 2010 Share Posted January 5, 2010 And the best way to display that div is with some jquery Jquery has an answer for everything, and that's the beauty about it Quote Link to comment Share on other sites More sharing options...
RaythMistwalker Posted January 5, 2010 Author Share Posted January 5, 2010 is there a tutorial on this? Im actually surprised how far i got with my pm system judging i only started php a few days ago Quote Link to comment Share on other sites More sharing options...
ChaosKnight Posted January 5, 2010 Share Posted January 5, 2010 For the jquery onclick function: http://docs.jquery.com/Tutorials:How_jQuery_Works You can also go through a lot of plugins, just search google.. W3Schools.com also have a jquery tutorial, you can even use OpenSocial jQuery or another where all the work has already been done for you Quote Link to comment Share on other sites More sharing options...
aeroswat Posted January 5, 2010 Share Posted January 5, 2010 is there a tutorial on this? Im actually surprised how far i got with my pm system judging i only started php a few days ago Just curious what kind of forum is this you are making? Quote Link to comment Share on other sites More sharing options...
RaythMistwalker Posted January 5, 2010 Author Share Posted January 5, 2010 Just curious what kind of forum is this you are making? Its not a forum its just the member section of a website but i coded a pm system for the members as well. If you want i can pm you the link and make you an account cos the accounts are admin controlled atm. Also: that jQuery tutorial isn't helping much. I loaded the script into a test web-page and it still loaded the link. I'm using firefox if this affects it Quote Link to comment Share on other sites More sharing options...
ChaosKnight Posted January 5, 2010 Share Posted January 5, 2010 jQuery is cross browser, so it doesn't matter what browser you use, did you include the jQuery correctly? Also, the download on the jQuery website puts a .js.txt extension at the back of the file, rename it to jquery.js jQuery normally has all the scripting you want to achieve, this speeds up development quite a lot... And always make sure you end the statements correctly, it won't throw out errors even though there are... e.g.: $(document).ready(function(){ $("a").click(function(event){ alert("As you can see, the link no longer took you to jquery.com"); event.preventDefault(); }); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.