Jump to content

PHP classes


bioTIN

Recommended Posts

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)];
    }

 

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

Link to comment
https://forums.phpfreaks.com/topic/166901-php-classes/
Share on other sites

i have to extract a lot info from mysql so i thought i could give classes a shot at. Well i did end up getting the result, but now im not able to extract it.

 

foreach($sub_details->mysql_fields as $key -> $value)

{

echo $key."->".$value;

 

}

 

throws an error, actually doesnt do anything, what should i do?

Link to comment
https://forums.phpfreaks.com/topic/166901-php-classes/#findComment-880346
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.