Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Thanked 0 Times in 0 Posts

    Cool Dynamically creating Tables

    I have a table 'course' in my database
    id semester channel course coursecode grade
    1 Sem1 Channel1 Digital Networks C70089 A
    2 Sem1 Channel1 Network Theory N00089 A+
    3 Sem1 Channel2 Data & Structur D70089 B
    4 Sem1 Channel2 Object Oriented C70089 A
    5 Sem2 Channel1 Micro Processors M70089 A
    6 Sem2 Channel1 Electricals EE0089 B+
    7 Sem2 Channel2 Elect & Communs EC7080 C
    8 Sem2 Channel2 Elect Labs LEO90 B+

    $query = mysql_query('SELECT * FROM course');
    I need the output dynamically with a query and looping like

    Sem1 Sem2
    Channel1 Channel2
    Course Code Grade Course Code Grade
    Digital Networks C70089 A Micro Processors ---- ----
    Network Theory N00089 A+ Electricals ---- ----

    Channel2 Channel2
    Course Code Grade Course Code Grade
    Data & Structur D70089 B Elect & Communs ----- -----
    Object Oriented C70089 A Elect Labs ----- -----

    Can anyone help me witht he php, mysql code
    Last edited by gansai; 09-29-2012 at 07:50 PM.

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    This data doesn't make sense to what you have in these example tables. You have "Micro Processors" on the same entry line as "Digital Networks", but no indication how you actually got to this combined record. Given the datatable you have here, there is no logical way to create this mix of courses, as there is no definitive relationship between multiple courses in this table.
    It looks like you are matching the first Sem1,channel1 with Sem2,Channel1, but this is an insufficient way to do this as you have multiple sem and multiple channel per sem. Since you MUST provide an order on your table, there is no guarantee as to the order of the records beyond that point. Typically it is by insertion order and you can force the order by the id, but if you change the data by removing, modifying or inserting anything, then it will cause a potential change in the ordering as it will not guarantee an implicit order.

    Unless this doesn't matter at all? The only logical way with what you have here would result in records much like the following:
    Digital Networks, Micro Processors
    Digital Networks, Electricals
    Network Theory, Micro Processors
    Network Theory, Electricals
    And so forth, repeated with the sem2 as well. I assume that this isn't what you want, so you'll need to come up with a way to actually relate one record to another.

  3. #3
    New to the CF scene
    Join Date
    Sep 2012
    Thanked 0 Times in 0 Posts
    Thank You for your kind response,

    I want to let you know there is a relation for sem, channel and course and how this works is

    Sem - Channel - Course

    I have tried the code and working 80%., but 20% issues are

    1. All the sems are displaying onebyone but need side by side.
    2. And under a channel Iam getting only one course, but there were 2 courses.


    Can you suggest me the way
    Last edited by gansai; 09-30-2012 at 09:15 AM.


Posting Permissions

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