I need code as follows: A counter that displays the number of users online. When the number reaches 10, I want it to trigger a javascript button (don't have it yet, but i will take care of that part) to come up so the users can press it. You can just echo "10 people are online" for now. I don't know if the page would have to refresh for the button to appear? So basically: If 10 people visit the page, then display javascript button If you know a better way of doing this, I am open to suggestions and comments. I know it may not be that hard, but I lack the programming knowledge. Can pay paypal.
<?php $timenow=time(); $select = mysql_query("SELECT * FROM table WHERE online > '$timenow' ORDER by id"); $num = mysql_num_rows($select); if($num < 9){ echo "$num"; } elseif($num > 9){ PUT JAVA CODE DOWN ERE } ?> PHP: I think thats right
thank you for your response cubz. but i don't understand what to do with that code. can you go into more detail? and how do i link it to the mysql database? Thanks
If you're going to do it like that, you may as well increase the efficiency. What's the point in selecting all the data if all you want is a count? Change it to: <?php $timenow=time(); $num = mysql_query("SELECT COUNT(id) FROM table WHERE online > '$timenow'"); if($num < 9){ echo "$num"; } elseif($num > 9){ PUT JAVA CODE DOWN ERE } ?> PHP: