i want to fetch titles and title’s tags.
public function titles()
{
$query=mysql_query("SELECT * FROM title");
while($row = mysql_fetch_object($query)){
$data->title[] = $row;
$data->tag[] = $this->tags($row->id);
}
return $data;
}
public function tags($title_id)
{
$query=mysql_query("SELECT * FROM tag WHERE title_id = '$title_id'");
while($row = mysql_fetch_object($query)){
$tag[] = $row;
}
return $tag;
}
I’m trying to print in this way
$data = titles();
foreach($data->title as $title)
{
echo $title->topic;
foreach($data->tag as $tag)
{
echo $tag->name;
}
}
but it doesnt work. How can I do?
thank you for help.
You should have something like this in your titles method
You also need to add files like this
Then you can loop like this
Also Enable error so that you can see PHP Errors .. at on top of your page
PHP DOC ON
mysql_***What i think your code should look like