12-08-2007, 02:53 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Oct 2007
Location: US
Posts: 66
Thanks: 19
|
Newbi OOP Question
I am just starting to learn OOP, this very moment, and I have a question. I got a few things done (more than expected), but I am having some problems.
I am trying to just get a post from a database based on the ID.
PHP Code:
class post { var $id; function set_post($id) { $this->id = $id; $post_query = mysql_query("SELECT * FROM `v7_posts` WHERE id = '$this->id'"); if(mysql_num_rows($post_query) < 1) { return false; } $this->title = mysql_result($post_query,'0',"title"); $this->post = mysql_result($post_query,'0',"post"); return true; }
function get_post() { return $this->title; return $this->post; }
}
Thats my class, and I'm using this to call it.
PHP Code:
$post = new post; $post->set_post("1"); echo $post->get_post();
My problem is, that it is only returning the title, not the actual content. Am I doing this completely wrong?
Thanks! 
|
|
|