title: php/mysql:what's the idea to active/inactive a code from being executed
body: <p>i have a php code to show online users,my question is that how to make an option(yes,no) in the admin panel to control the appearance of enabling or disabling the code</p>
  
  <p>just i want to know the idea for making something like that?what are the fields required?what are the queries to do that?</p>
  
  <p>or an article discuss the process of activate or in activate some code from being executed according the state of selected option(y,n)</p>
  
  <p>and a practical snippet for that.......</p>
  
  <pre><code>    session_start();
  $session=session_id();
  $time=time();
  $time_check=$time-600; //SET TIME 10 Minute
  
  $host="localhost"; // Host name
  $username="advphp_advphp"; // Mysql username
  $password="112233"; // Mysql password
  $db_name="advphp_download"; // Database name
  $tbl_name="user_online"; // Table name
  
  // Connect to server and select databse
  mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
  mysql_select_db("$db_name")or die("cannot select DB");
  
  $sql="SELECT * FROM $tbl_name WHERE session='$session'";
  $result=mysql_query($sql);
  
  $count=mysql_num_rows($result);
  
  if($count=="0"){
  $sql1="INSERT INTO $tbl_name(session, time)VALUES('$session', '$time')";
  $result1=mysql_query($sql1);
  }
  else {
  "$sql2=UPDATE $tbl_name SET time='$time' WHERE session = '$session'";
  $result2=mysql_query($sql2);
  }
  
  $sql3="SELECT * FROM $tbl_name";
  $result3=mysql_query($sql3);
  
  $count_user_online=mysql_num_rows($result3);
  
  echo "المتواجدون الان : "; echo $count_user_online + 30;
  
  // if over 10 minute, delete session
  $sql4="DELETE FROM $tbl_name WHERE time&lt;$time_check";
  $result4=mysql_query($sql4);
  
  mysql_close();
  </code></pre>