UPDATE 1:
I forgot to add GetTags()
method, so here it is:
public $blog_tags;
public function GetTags()
{
return $this->blog_tags;
}
=========================================================================
I'm working with PHP OOP to develop my project. Basically I have a table called blogs
which contains some fields and data like this image:
Then I created a class Blos.class.php
and made two methods as below:
public function ShowTag()
{
$tag = $this->_db->prepare("SELECT blog_tags FROM blogs");
$tag->execute();
while($row = $tag->fetch())
{
$this->blog_tags = $row['blog_tags'];
}
}
public function NumTag()
{
$cat = $this->_db->prepare("SELECT blog_tags FROM blogs");
$cat->execute();
$row_cat = $cat->rowCount();
return $row_cat;
}
Then in order to retrieve data on screen, I did this:
$tagSet = new Blogs();
$tags = $tagSet->NumTag();
$tagShow = $tagSet->ShowTag();
if(!empty($tags)){
$tagShow->GetTags();
}else{
echo "There is no tag available right now!";
}
But the problem is I get this error message:
Fatal error: Uncaught Error: Call to a member function GetTags() on null in line 20
Which is this line:
$tagShow->GetTags();
So what is the mistake with that ? Can you please help me ?