Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-29-2012, 06:45 PM   PM User | #1
gansai
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
gansai is an unknown quantity at this point
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 06:50 PM..
gansai is offline   Reply With Quote
Old 09-29-2012, 07:04 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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:
Code:
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.
Fou-Lu is offline   Reply With Quote
Old 09-30-2012, 08:03 AM   PM User | #3
gansai
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
gansai is an unknown quantity at this point
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.

http://codepad.org/OYvfGwcK

Can you suggest me the way

Last edited by gansai; 09-30-2012 at 08:15 AM..
gansai is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:36 PM.


Advertisement
Log in to turn off these ads.