在href标记中动态填充查询字符串

时间:2012-11-26 18:14:37

标签: php get query-string dynamically-generated

我想提出一个问题。我有一个index.php文件,动态填充数据库中包含的所有章节。 我的代码是这样的:

foreach($chapters_titles as $title){
     echo  "<a href='index.php?chapter_id=1>". $title ['title']."</a>";
}

foreach($chapter_contents as $content){
     echo  "<br/>". $content;
}

当我点击子章节时,当我点击章节标题和子章节的内容时,我希望能够看到每章的子章节。 我怎样才能做到这一点?

我知道在页面顶部我会有一段像

这样的代码
if(isset($_GET['chapter_id'])){
     code
}

if(isset($_GET['sub-chapter_id'])){
     code
}

我真的很感激任何指针。

0 个答案:

没有答案
相关问题