I have a table with structure as:
CREATE TABLE `lectures` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`category` varchar(255) NOT NULL,
`semester` varchar(255) NOT NULL,
`course_no` varchar(255) NOT NULL,
`course_title` varchar(255) NOT NULL,
`faculty_name` varchar(216) NOT NULL,
`upload_file` varchar(255) NOT NULL,
`dateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
Now the scenario is, I have 3 things; semester, course and lecturer. There can be more than one semesters, each semester can have multiple courses and each course can be have many lecturers. Above DB table have all the data in it. I want to populate data in HTML table whose structure can be as follows.
I want to populate data in above pic format. I can't figure out how to do that.
Any help appreciated.
When you write the query, add an additional column say 'CourseClass'. Make the CourseClass equal to the name of the course.
Once you have a table with your data and the additional column, you can write jquery or js to merge the rows with similar values.
At the front-end, simply hide the extra column you added.
Alternatively, you can look this up. The person is trying to achieve something similar - html table span if the data is same
There is a JSFiddle link in there too.
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.