--- loncom/interface/lonmysql.pm	2002/07/26 16:22:24	1.1
+++ loncom/interface/lonmysql.pm	2002/07/28 18:21:13	1.2
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # MySQL utility functions
 #
-# $Id: lonmysql.pm,v 1.1 2002/07/26 16:22:24 matthew Exp $
+# $Id: lonmysql.pm,v 1.2 2002/07/28 18:21:13 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -330,19 +330,26 @@ sub disconnect_from_db {
 
 =pod
 
-=item &query_table()
+=item &number_of_rows()
 
-Currently unimplemented.
+Input: table identifier
+
+Returns: the number of rows in the given table.
 
 =cut
 
 ###############################
-sub query_table { 
-    # someday this will work.
+sub number_of_rows { 
+    my ($table_id) = @_;
+    # Update the table information
+    my %Table_Info = %{&get_table_info($table_id)};
+    # return the number of rows.
+    if (defined(%Table_Info)) {
+        return $Table_Info{'Rows'};
+    }
+    return undef;
 }
 
-
-
 ###############################
 
 =pod
@@ -577,7 +584,7 @@ Inputs: $table_id,$condition
 
 Returns: undef on error, an array ref to (array of) results on success.
 
-Internally, this function does a 'SELECT * FROM table HAVING $condition'.
+Internally, this function does a 'SELECT * FROM table WHERE $condition'.
 $condition = 'id>0' will result in all rows where column 'id' has a value
 greater than 0 being returned.
 
@@ -587,7 +594,7 @@ greater than 0 being returned.
 sub get_rows {
     my ($table_id,$condition) = @_;
     my $tablename = &translate_id($table_id);
-    my $request = 'SELECT * FROM '.$tablename.' HAVING '.$condition;
+    my $request = 'SELECT * FROM '.$tablename.' WHERE '.$condition;
     my $sth=$dbh->prepare($request);
     $sth->execute();
     if ($sth->err) {