<?php 
use WHMCS\Database\Capsule;
require __DIR__ . '/init.php';
	
	$rowsData = Capsule::select("SELECT d.domain,c.* FROM tbldomains d INNER JOIN expiredomain_temporary dt on dt.domain=d.domain INNER JOIN ResellersCenter_ResellersClients rsc on rsc.client_id=d.userid INNER JOIN ResellersCenter_Resellers rs ON rs.id=rsc.reseller_id INNER JOIN tblclients c ON c.id=rs.client_id order by c.id ASC");
	//echo '<pre>'; print_r($rowsData); die();



?>

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
            
  <table class="table">    
    <tbody>
    <?php
$arr = array(); 

foreach ($rowsData as $rowData)
{
    if(!in_array($rowData->id, $arr))
    {
    	$i=1;
     ?> 
      <tr>
      	<th><?php echo $rowData->id; ?></th>
        <th><?php echo $rowData->firstname.' '.$rowData->lastname; ?></th>
        <th><?php echo $rowData->email; ?></th>
        <th><?php echo $rowData->phonenumber; ?></th>
      </tr>    
      <tr>
        <td colspan="4"><?php echo '('.$i.')  '.$rowData->domain; ?></td>
      </tr>
     <?php 
     $arr[] = $rowData->id;
 	}else{ $i++; ?>
 	 <tr>
        <td colspan="4"><?php echo '('.$i.')  '.$rowData->domain; ?></td>
      </tr> 
<?php
 	}
} 
 ?> 
    </tbody>
  </table>
</div>

</body>
</html>