我想获取标题和标题的标签。
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;
}
我正在尝试以这种方式打印
$data = titles();
foreach($data->title as $title)
{
echo $title->topic;
foreach($data->tag as $tag)
{
echo $tag->name;
}
}
但它不起作用。我能怎么做?谢谢你的帮助。