Hi,
Each company has more than one record in the “teklif” table
How can I show the information and total number of each company on a single line separately?
My aim is to show the number of companies from largest to smallest (such as statistics)
Company information is
- Company authorized Name Surname
- Company Name
- Total Registration of the Firm
Sample
Adem GENÇ --|-- Company --|-- 7
Ahmet SAYDAM --|-- Company --|-- 5
as
I want to show this information in pagination system
if(isset($_POST['per'])){
$limit = $_POST['per'];
}
else
{
$limit = '10';
}
$sql = 'SELECT
teklif.name_surname,
members.company
FROM teklif
LEFT JOIN members ON teklif.member_id = members.member_id
ORDER BY members.company DESC ';
$page = 1;
$start = 0;
if(!empty($_POST["page"])) {
$page = $_POST["page"];
$start = ($page-1) * $limit;
}
$limit_code = " LIMIT " . $start . "," . $limit;
$pagination_statement = $PDOdb->prepare($sql);
$pagination_statement->execute();
$top_row = $pagination_statement->rowCount();
$query = $sql.$limit_code;
$pdo_statement = $db->prepare($query);
$pdo_statement->execute();
$companyarray = $pdo_statement->fetchAll();
I tried to do something like above but for pagination I want it to count each group once instead of counting each row
I tried to do something like below, I listed one from each group, but since the pagination system counts each row, the number of rows listed is 2 while the second page occurred in the pagination
$companyarray = $pdo_statement->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_COLUMN);
foreach ($companyarray as $name_surname => $company) {
echo "Name Surname: ".$name_surname." Company: ".$company." Total rows: ".count($company)."<br>";
}
I will be glad if you help
Thank you from now