Note that there are some explanatory texts on larger screens.

plurals
  1. POCounting with PHP from a dynamictable
    primarykey
    data
    text
    <p>I'm not an expert in PHP even though I've been working with some stuff, copying and pasting from here and there, well I want to ask something that I can not find and that I don't have the slightest idea on how to implement it.</p> <p>For instance, at a table like this:</p> <pre><code> +------+-----+ |NAME |BIRTH| +------+-----+ |John |1980 | |Carl |1982 | |Alice |1990 | |June |1994 | |Rob |1998 | |Alice |1998 | |John |2000 | |Alice |2001 | |Etc. | | +------+-----+ </code></pre> <p>I do different queries, like these below (and I could keep doing queries with any combination of years):</p> <ol> <li><code>Select * from table where BIRTH between 1980 and 1990</code></li> <li><code>Select * from table where BIRTH between 1980 and 2001</code></li> <li><code>Select * from table where BIRTH between 1990 and 2001</code></li> </ol> <p>So I will get 3 different tables, and from those tables I need to count the different contents, for instance, from the table obtained with the query1 I need to obtain:</p> <pre><code> John = 1 Carl = 1 Alice = 1 </code></pre> <p>from table of query2:</p> <pre><code> John = 2 Carl = 1 Alice = 3 June = 1 Rob =1 </code></pre> <p>from table of query3:</p> <pre><code> Alice = 3 John = 1 Carl = 1 June = 1 Rob =1 </code></pre> <p>And remember the big table has 700 records, so it could appear any new name, and I need to print out the result in the same way:</p> <pre><code> Alice = 3 John = 1 NewName = 1 June = 1 Rob =1 </code></pre> <p>My final goal is do percentages in relation to the obtained table, and not to the total of registers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload