Mysql help needed: getting number of items in table column

xprtweb

New Member
Messages
30
Reaction score
0
Points
0
Hi
I am quite new to Mysql as my question probably shows.
I need some help to get the number of contents in a column s1t1 in table "itmc_anmeldungen".
My attempt:
---------------------
$abfrage = "SELECT id,vorname,nachname,strasse,plz,ort,tel,email,firma,s1t1,s1t2,s1t3,s2t1,s2t2,s2t3,signupdate,user_ip,activated,lastlogin FROM itmc_anmeldungen ORDER BY id";
$result = mysql_query($abfrage) or die(mysql_error());

$totalsum = mysql_num_rows($result);
$pix = mysql_num_fields($result);
if($totalsum)
{
echo "There are <b>$totalsum</b> results in the database<P>";
echo $pix."<p>";
}
This i know returns the number of rows in a table.
---------------------------
$ergebnis = mysql_query('SELECT * FROM itmc_anmeldungen WHERE s1t1 != ""');
(I wanted the s1t1 fields that are not empty - this did not work)

$rex = mysql_num_fields($ergebnis);

if (!$rex)
{
die('Could not query:' . mysql_error());
}
else
{
echo "<p> There are <h4>$rex</h4> results in db.";
}
----------------------------
In the 2 cases, the number of results returned is the same, which is actually the total number of rows.
I however want to get the total number of items in each column with the second function, like s1t1 OR any other like "firma".
What function(s) do I use to do so?
Is there any function I can use to get the number of items in each individual column & I can select which to print, ie like those in the whole table itmc_anmeldungen?

Please note I'm a MySQL Newbie, so be clear & if possible use the examples above to answer my question. (I did not find any online tutorial addressing my question fast enough. I urgently need a solution)

Thanks & regards.
 
Last edited:

websoul

New Member
Messages
39
Reaction score
0
Points
0
select count(s1t1) from itmc_anmeldungen;

Hope this helps
 
Top