beginner question. I count rows like this (and it's working like a charm):
Code: Select all
global $database;
$sql = "SELECT * FROM #__table_2";
$database->setQuery($sql);
$rows = $database->loadObjectList();
$cntrows = count($rows);
echo "<p>There are currently <strong>".$cntrows."</strong> rows</p>
How do i count columns now? My table currently looks like this:
ID
Name
Name2
Name3
Name4
the thing is that the user is able to enter only a name or additional names, so code should take care of that too. The end result should be something like "There are currently x rows with y additional names."
Something like IF column "Name2" NOT NULL count++ AND IF COLUMN "Name3" NOT NULL count++... - I just have no clue how to write that in PHP.
Thanks in advance
moontear
PS: I know there is the "mysql_numfields" function, but I don't know how to implement it with the Joomla special coding (e.g. $database->setQuery($sql); etc)