hi, saga
overall I have read whole thread, and have this summary if you wish to
1.) only wanted the no. of records(rows) with a sub-set of all records.
you can do this as following, let's say we have a table (table1) with 3 fields:
id, role, groups, then:
CODE
k:\mysql\bin>mysql<enter>
mysql> show tables;
+--------------------+
| Tables_in_test_db2 |
+--------------------+
| table1 |
+--------------------+
1 row in set (0.00 sec)
mysql> select * from table1;
+----+------+--------+
| id | role | groups |
+----+------+--------+
| 1 | 0 | 0 |
| 2 | 1 | 0 |
| 3 | 5 | 0 |
+----+------+--------+
3 rows in set (0.00 sec)
mysql> select count(*) from table1 where role=0;
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
mysql> select count(*) from table1 where groups=0;
+----------+
| count(*) |
+----------+
| 3 |
+----------+
1 row in set (0.00 sec)
as you can see the result that return a value(1, 3 above) with a field named (count(*)). then, you can use :
a.) $row = mysql_fetch_array($result)
b.) $numrow = $row[0];
in fact, you can use $row = mysql_fetch_row($result) also, but that required you modify the sql statement, you can have a reference to mysql mannual 2.) as other forum members stated, you use:
$roleid = 0;
$sql = "SELECT * FROM messages WHERE role=$roleid";
$result = mysql_query($sql);
$rownum = mysql_num_rows($result);
$row = mysql_fetch_row($result) ==> for get row
- hope this help
- Eric
Comment/Reply (w/o sign-up)