<?php
include '../../db_connect.php';

  if($_GET['mode']=='buyercode'){
	  
	  $items = mysqli_query($con,"SELECT compid, name, address, cmpcity, pincode, rtmst, rtvalue, discount, broker, ftype FROM commst");
   
	  while($row = mysqli_fetch_array($items)) 
	  {
		  echo $row[compid]."|".$row[name]."|".$row[address]."|".$row[cmpcity]."|".$row[pincode]."|".$row[rtmst]."|".$row[rtvalue]."|".$row[discount]."|".$row[broker]."|".$row[ftype]."\n";
	   
	  }
  }

  else if($_GET['mode']=='agentcode'){
	  
	  $items = mysqli_query($con,"SELECT compid, name FROM commst ");
   
	  while($row = mysqli_fetch_array($items)) 
	  {
		if (strpos(strtolower($row['compid']), $q) !== false) 
		{
		  echo $row[compid]."|".$row[name]."\n";
		}
	  }
  }

  else{
	$items = mysqli_query($con,"SELECT compid, name, address,type FROM commst");
   
	  while($row = mysqli_fetch_array($items)) 
	  {
		
		  echo $row[compid]."|".$row[name]."|".$row[address]."|".$row[type]."\n";
		
	  }
  }
  
mysqli_close($con);
?>