The file includes the following main columns that are used to make the list:
Program
Course
Section
Books
In each Program, there are several Courses. In each course, there are several Sections. In each section there are several books.
I've been able to put together the code that will create the nested list, but I want to change it slightly, and haven't been having much luck.
Here's the important part of what I've got:
Code: Select all
$currentGroup = '' ;
$currentCourse = '' ;
$currentSection = '' ;
$g = 0;
$c = 0;
$s = 0;
foreach ($filedata as $line_num => $line) {
$books = explode(';',$line);
if ($currentGroup != $books[0] )
{
if($g > 0)
{
echo "</ul></li></ul></li></ul></li>";
}
$g++;
$c=0;
$s=0;
$currentGroup = $books[0] ;
echo "<li>".$currentGroup."<ul>" ;
}
if ($currentCourse != $books[1])
{
if($c > 0)
{
echo "</ul></li></ul></li>";
}
$c++;
$s=0;
$currentCourse = $books[1] ;
echo "<li><a style=\"text-decoration:none; color:#333333;\" title=\"".$books[3]." ~ ".$books[4]."\">".$currentCourse."</a><ul>" ;
}
if ($currentSection != $books[2])
{
if($s > 0)
{
echo "</ul></li>";
}
$s++;
$currentSection = $books[2] ;
echo "<li><a style=\"text-decoration:none; color:#333333;\" title=\"".$books[3]." ~ ".$books[4]."\">Instructor: ".$books[4]."</a><ul>" ;
}
$coursename = $books[3];
$instructor = $books[4];
$isbn = $books[5];What I want to change is to go from this:
Program
- Course 1
-- Section 1
--- Book 1
--- Book 2
-- Section 2
--- Book 1
to this:
Program
- Course 1 (Section 1)
-- Book 1
-- Book 2
- Course 1 (Section 2)
-- Book 1
in this case, I'd want to put the Section number or Course Instructor as a tool-tip on hovering over the Course.
What do I need to change in my code to make this work?
I've tried changing the nesting, but so far have ended up with incorrect results.
Thanks,
Scott
PS. You can see how it currently works here: http://store.multipleangles.com - the menu on the right