<?php
include("../conn.php");
 ?>
<?php
$sql="select userid from chat_user where companyname='".$_GET['companyname']."'";
mysql_query("set names 'utf8'",$dbconn);
$result=mysql_query($sql,$dbconn);
if(mysql_num_rows($result)>0)
{
echo mysql_result($result,0,'userid');
}
else
{
$sql="select userid from chat_user order by userid desc limit 0,1";
$result=mysql_query($sql,$dbconn);
   if(mysql_num_rows($result)==0){
      $getthisid=1;
    }else{
      $getthisid=mysql_result($result,0,'userid')+1;
   }
echo $getthisid;
}
mysql_close($dbconn);
 ?>