Hello.
I’d be happy if I get some help for a statistics that struggle to make.
My goal is to show how many iterations (set to static array) in every column from mysql result. (hopefully express myself correctly.)
Static arrays are 3 and used to convert numbers into meaningful information.
For example:
[php]<?php
$proffNames =
array
(
1 => “Cook”,
2 => “Guardian”,
3 => “Master”,
4 => “Cashier”,
5 => “Doctor”,
6 => “Driver”,
7 => “Manager”,
8 => “Opreator”,
9 => “Programmer”,
11 => “Service”
);
$genderNames =
array
(
0 => “Male”,
1 => “Woman”
);
$nationalNames =
array
(
1 => “Bulgarian”,
2 => “Romanian”,
3 => “German”,
4 => “Spanish”,
5 => “Italian”,
6 => “French”,
7 => “Russian”,
8 => “Greek”,
10 => “English”,
11 => “Austrian”
);
?>[/php]
With mysql query I care (if at all what I need to show from mysql), but I have difficulties with the calculation.
Mysql query to the server is the following.
I redefined a variable to be used in mysql select.
Suppose that in this case is 34
/* $checkedId = 34; */
SELECT
`account`.`national`,
`account`.`proff`,
`account`.`age`,
`account`.`gender`
FROM `account`
LEFT JOIN `group_account` ON `group_account`.`id` = `account`.`id`
WHERE `group_account`.`groupId` = $checkedId AND `account`.`age` >= 10
Results for this query looks like this:
+----------+-------+-----+--------+
| national | proff | age | gender |
+----------+-------+-----+--------+
| 4 | 11 | 71 | 0 |
| 1 | 2 | 26 | 1 |
| 1 | 2 | 46 | 1 |
| 4 | 1 | 12 | 0 |
| 11 | 2 | 32 | 1 |
| 4 | 6 | 62 | 1 |
+----------+-------+-----+--------+
My problem has a solution with several requests to mysql server, but I want the query to be optimized (subject to resources)
The goal is as I wrote above I get something like this:
Nationality:
Bulgarian (Count)
Romanian (Count) …
occupations:
Cooks (Count)
Drivers (Count)
Managers (Count) …
Similarly for the other 2 columns.
Can you point me to an example to spare several days searching.
Thanks in advance.