0

我有一个数据库结构如下:

 tbl_topic                                 tbl_chapter
 -pk id (AutoIncrement)                    -pk id
 -fk parent_id  (references itself)        -chapter_name
 -fk chapter_id (references tbl_chapter)
 -name
 -description
 -teaching_hours
 -teaching_periods

一个主题有章节,章节有主题(主题可能有子主题等)。首先,我需要设计一个表单,用户可以在其中向特定章节添加主题,如下所示:

  Chapter 1: Science: (Add topic +)
    1.Topic:   Name:_____  Description: _____ Hours _____(Add topic +)
       Topic   Name:_____  Description: _____ Hours _____(Add topic +)
          Topic   Name:_____  Description: _____ Hours _____(Add topic +)
    2.Topic:   Name:_____  Description: _____ Hours _____(Add topic +)
       Topic   Name:_____  Description: _____ Hours _____(Add topic +)

我只需要一个算法或步骤,或者一个关于如何分层插入元素并以某种语言(如 php 或 jsp)获取元素层次结构的提示。另外,如果这个数据库设计不好,请给我一个更好的结构方法。

4

1 回答 1

0

这是我在我的项目中所做的

处理主页上的新闻对象 .News 将来自数据库作为 json 字符串

然后

if(!(news ==null)){
         for(var i=0; i < news.list.length; i++){
        $(news.list[i]).attr("clientid" ,i);
        var listItemDiv = $("<li id="+news.list[i].clientid+"><h3>"+news.list[i].title+"</h3><span class=date>Department:"+getDepartmentName(news.list[i])+" "+getSubDepartMentName(news.list[i])+"<span><span class=date>Opening Date:"+news.list[i].startDate+"<span><a target='_blank' style='float:right' href='docdetails?docid="+news.list[i].id+" ' >Read More..</a></li></br>");
            $('#newsitems').append($(listItemDiv));

        }  

在你的情况下,你有另一个循环来迭代chapter.list objects

祝你好运 。

于 2013-01-28T08:54:44.923 回答