I have tried understanding classes in PHP, but I am not even able to start writing a class for the below code: $fieldnames=mysql_list_fields(fcsubscription,regular); $fieldnames1=mysql_num_fields($fieldnames); for ($index=0; $index < $fieldnames1; ++$index) { $mysql_fields[mysql_field_name($fieldnames, $index)]=$cleantake[mysql_field_name($fieldnames, $index)]; } $subnames=mysql_list_fields(fcsubscription,sub_details); $subnames1=mysql_num_fields($subnames); echo "total number is ".$subnames1; for($index=0;$index<$subnames1;++$index){ $sub_fields[mysql_field_name($subnames,$index)]=$cleantake[mysql_field_name($subnames,$index)]; } PHP: as you can see, I call for the field names from the database and then take values from an array based on the earlier retrieved field names. Now how do I go about writing a class with variables changing? If you could explain how a class could be created for this one line :$sub_fields[mysql_field_name($subnames,$index)]=$cleantake[mysql_field_name($subnames,$index)]; } i think ill be able to manage with the others. thanks