Page 1 of 1

SQL Query Help

Posted: Mon Jul 23, 2007 11:23 pm
by truepal20032001
can some one help me word a sql query that selects the total amount of columns in the table, ex:

====================================
id | text | text 2 |
====================================
1 | dddf | dddd
________________________________________|

2 | dddf | dddd
________________________________________|

3 | dddf | dddd
________________________________________|

4 | dddf | dddd
________________________________________|

^
||

I want it to output 4

Posted: Mon Jul 23, 2007 11:29 pm
by feyd
That's number of rows/records.

The COUNT() function may be useful.

Posted: Fri Jul 27, 2007 5:07 pm
by califdon
I assume, as did feyd, that you mean rows, not columns. If so, I would just do something like:

Code: Select all

...
$result=mysql_query('SELECT * FROM xxx');
$nr=mysql_num_rows($result);