Counter merge items

Dear All,

on the website for our event i have a few counters made, but now i need some help.

one of my tables has all the field values of all registered participator.
now i have made a counter which can count one field ID and group them by field value, no problem so far. (see below code)

$query = "SELECT * , COUNT(*) FROM jos3e_eb_field_values WHERE field_id = 19 GROUP BY field_value";
if ($result = $mysqli->query($query)) {
    /* fetch associative array */
    while ($row = $result->fetch_assoc()) {
/*printf ("%s (%s)\n", $row["field_value"], $row['COUNT(*)']);*/
echo "<td>&nbsp&nbsp" . $row [field_value]."</td>";
echo "<td>&nbsp;&nbsp;&nbsp;&nbsp" , $row['COUNT(*)'] . "</td>";
echo "</tr>";

now i will tell the problem.
Field ID 19 and 20 have a item that i translate in different languages ( sizes for T-shirts)
for example - Men - L / Heren - L / Herren - L
with the counter above these are counted separate.
is it possible that i merge these items ?

i know the best is to do this on entry but the program i use works on this way (event booking)

i hope someone can help me

grtz from holland
manfred vd Waarsenburg

Welcome to the site. I am sure we can help, but, you problem is not clear.
If you have multiple entries in a row, you can combine them into one display in a table.
Is that what you want to do?

You can combine anything into one cell or TD of a table. Not sure if that is what you need.

You could do this in MySQL by creating and then grouping by a generated field; your SQL would look something like this:

    IF(field_value IN ("Men - L", "Heren - L", "Herren - L"), "Men - L", field_value) AS translated_val
FROM jos3e_eb_field_values
GROUP BY translated_val;

You’ll then have to use translated_val in your code instead of field_value.

These entries really, REALLY should be using the same language in the database though. The above method doesn’t scale very well when you start adding (“Men - S”, “Heren - S”, “Herren - S”) etc. You’re setting yourself up for a great deal of pain if you try to make this work in the way you describe. I’d suggest looking harder at the program you’re using and see if it has any support for multiple languages.


thanks for the help.
What i want is 1 number for (Yes, Ja) and 1 number for (Nein, Nee, No)


Yes - 153
No - 68


Well, Mvdw310, you switched from T-shirts to YES/NO answers… Confusing…

So, to add up fields with different values you could try it this way:

    SUM(Ja)+SUM(Yes) AS total_yes, SUM(Nee)+SUM(Nei)+SUM(Nein)+SUM(No) AS total_no
    FROM jos3e_eb_field_values

You can COUNT any one field OR you can SUM the amounts in a field. And, once summed, you can add those values together to create a grand total. This example assumes you have those fields in your database table. Ja, Nee, Nein, No, Yes In your first post you talked about T-shirts of different sizes.

I am not sure this helps, but, perhaps you need to explain further what you are attempting to do. What does your table structure actually look like? That might help us give you better help.

Sponsor our Newsletter | Privacy Policy | Terms of Service