I want to make table in HTML. First column should be names of people and next columns should be date of lessons. I would like to make something like school attendance. When someone was in class the cell should be green when I click on it otherwise it should be white. I want to select names of users and names of lessons from database. How shoul I write good select query that can do what i want?
SCHEME OF TABLE USERS: - id (tinyint) - name (varchar) - password (varchar) md5
SCHEME OF TABLE LESSONS: - id (tinyint) - name (date)
I make an example of data that I want to get:
http://jsfiddle.net/k8UgT/207/
HTML:
<table>
<tr>
<th>NAME</th>
<th>25.10.</th>
<th>26.10.</th>
</tr>
<tr>
<td>Jack</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Sam</td>
<td></td>
<td></td>
</tr>
</table>
JQUERY:
$( function() {
$('td').click( function() {
$(this).toggleClass('on');
} )
});
You should have a new table, let's say users_lessons_date
with the following structure:
(int)
- foreign key table_users (int)
- foreigg key lessons (datetime)
And your query, if you're using mysql and you want all date where a user was to lesson, will be:
select dateOfLesson, lessons.name as lessonName, table_users.name = userName
from users_lessons_date uld
join table_users u on ( uld.userId = u.id )
join lessons l on (uld.lessonId = l.id)
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.