$sql="SELECT num FROM count where dept='$dept' AND
deptsub='$deptsub'";

-------------------- begin of replace ------------------------------
   $result = mysql_query($sql,$db);
   $page_count = mysql_num_rows($result);
   # If does not exist in the database, insert a new entry

   if (!$page_count){

---------------------- end of replace ------------------------
     $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0');
     $result = mysql_query($sql,$db);
   }

   #Update the count in the database
   $page_count = $page_count + 1;
   $sql="UPDATE count SET num='$page_count' WHERE dept='$dept' AND
deptsub='$deptsub'";
   $result = mysql_query($sql, $db);

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to