What I meant was that, eventually, I would like to populate each row with unique data, regardless of the source - but that I wanted to provide the data for the output from the instance of the class, not from within it.
The reason for this is that when I create instances of this class, I may wish to populate it with different combinations of data - therefore precluding the idea of running a single method
within the class.
For example:
Code: Select all
function create_Rows ( ) {
$host = |||||||||||;
$db = |||||||||||;
$un = |||||||||||;
$pw = |||||||||||;
// mysql_connect ( $host,$un,$pw );
mysql_connect ( $host,$un,$pw );
mysql_select_db ( $db );
$sql = "SELECT * FROM users";
$result = mysql_query ( $sql ) or die ( "Could not perform query - ". mysql_error () );
$rows = mysql_num_rows ( $result );
$num = 1;
while ( $num <= $rows ) {
$data = mysql_fetch_assoc ( $result );
echo "<tr><td>". $data[notes] ."</td><td>Function call: ". $this->add_Data ( ) ."</td></tr>\n";
$num++;
}
} // end of function create_Rows ( )
called within the class itself outputs a set of results presented in a particular way. I may wish to present it in a slightly different way depending on the environment in the page on which the class is called, so would naturally want to have a different function that does this.
How would I instantiate the class and define which method to call for this purpose from outside the class? I would like to use the syntax $this->table_structure = function_x(); or, alternatively, function_y() , or something similar... thereby defining from the calling page which method should be used.
What is the right way to acheive this?