$sql = mysql_fetch_array($sql);
You get only first row from your query...
you should create one instance first
$obj_db=new Database();
$obj_db->Query("SELECT FROM products");
//$database=new Database("SELECT FROM products");
echo $obj_db£_>rows;
This is my database_query class....just a sample HTH
function get_table_field_record($table_name,$field_list,$where_clause="",$distinct="N")
{
//$field_list is SQL result fields return ,choose '*' if you want to return all
/*-------------function example
if ($arr=Get_Table_field_Record("users","Usr_ID,Usr_Name,Usr_Status","usr_status='Y'"))
{
foreach($arr as $list)
{
foreach($list as $field=>$value)
{
echo "$field ---- $value <br>";
}
}
}
example end------------------------*/
$i=0;
$dis=($distinct=="Y")?"distinct ":"";
if ($field_list<>"*")
{
$sql_str="select ".$dis.$field_list." from $table_name";
}else
{
$sql_str="select ".$dis."* from $table_name";
}
if (!empty($where_clause)) $sql_str.=" where ".$where_clause;
if ($qry=mysql_query($sql_str) or die ("query error!".$sql_str))
{
while ($rst=mysql_fetch_array($qry))
{
$result_array[$i]=$rst;
$i++;
}
return $result_array;
}
return false;
//end of get_table_field_record;
}