Hi guys,
I've been working with PHP for a while, and now moving onto OOP, which is proving to be annoyingly hard!
I know it might be 're-inventing the wheel', but I'm trying to understand how it all slots together and works, so please hold back a little ;].
The following function is supposed to get the arguments chucked through and run a query, which works fine, i also count the rows in it.
However, I want to print the results of the loop as you would normally but OOP in mind.
I can loop it and style it easily within the function, but because I may want this data again and again (in different formats across the site), i want to be able to print it out by calling in the class/function.
How would I do this?
Any tips? What am I doig wrong and/or misunderstanding?
Code is as follows:
public $numOfQuery;
public function select($table, $rows = "*", $where = null, $order = null) {
$query = "SELECT " . $rows . " FROM " . $table . "";
if ($where != null) {$query .= " WHERE " . $where . "";}
if ($order != null) {$query .= " ORDER BY " . $order . "";}
$getQuery = @mysql_query($query);
$this->numOfQuery = mysql_num_rows($getQuery);
}