www.webdeveloper.com
Results 1 to 5 of 5

Thread: mysql

  1. #1
    Join Date
    Aug 2010
    Posts
    11

    mysql

    i have this table..
    http://i5.photobucket.com/albums/y17...alam/dbase.jpg

    and i want to have an output like this..
    http://i5.photobucket.com/albums/y17...lam/output.jpg

    i don't know how to select the subjects once.. I've already tried the DISTINCT function and GROUP BY function but the subjects only gone out of placed in the table, they were not properly arranged..

  2. #2
    Join Date
    Sep 2010
    Posts
    160
    I am not sure you can.

    It would be easier to select them all like your dbase.jpg and then have some logic that removes the multiple subjects and displays them like your output.jpg.

    Archie

  3. #3
    Join Date
    Aug 2010
    Posts
    11
    I've already tried several logic but i failed

  4. #4
    Join Date
    Sep 2010
    Posts
    160

    resolved

    Well, what I would do is most likely make a query that simply returns all the rows that you present there (let us say it is for a week).

    So a query might look like this:

    SELECT time, weekday, subject FROM table WHERE week = <some week>

    each row looks like this then

    time | weekday | subject
    7:30 | monday | PRGLF - IT
    8:30 | monday | PRGLF - IT
    9:30 | monday | PRGLF - IT
    10:30 | monday | PROG2 - IT
    etc

    Then in your PHP I would create a class (for example Subject) that represents each subject, with a an array that has the keys mathing the weekdays and entries for the times (in another array).

    class Subject {
    $subjectName;
    $weekdays = array(<for each weekday, you have an array of the times))
    }

    Then you can create your table and use the length of the times as colspan for each subject.

    Hope that helps,

    Archie
    Last edited by zimonyi; 10-18-2010 at 08:29 AM.

  5. #5
    Join Date
    Aug 2010
    Posts
    11
    i got it.. thanks for the help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles