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 08-27-2006, 12:26 PM   PM User | #1
musher
Regular Coder

 
musher's Avatar
 
Join Date: Jan 2005
Location: Minnesota
Posts: 203
Thanks: 0
Thanked 0 Times in 0 Posts
musher is an unknown quantity at this point
one more for the nite then bed time, question on Joins

I think this is working ok (it looks like, the right stuff is showing up, in the right order).
Not real sure on inner/outer/left and what ever else type of joins, still have some reading to do.
PHP Code:
$result mysql_query("SELECT a.ID, a.menu_id, a.submenu_title, a.display_order, b.menu_title, b.display_order FROM page_content as a JOIN menu as b ON (a.menu_id=b.ID) ORDER BY b.display_order,a.display_order",$db); 
Any way here's my question, I have two fields in the tables that are named the same "display_order" and I cant figure out how to access both from this querry?
PHP Code:
$var_menu_title $MyRow['menu_title'];
$var_submenu_title $MyRow['submenu_title'];
$var_menu_order $MyRow['display_order']; 
I am able to get menu_title from table b, submenu_title from table a, but display_order gives me display_order for table b(menu), I would have thought that would give me display_order for table a(page_content). how would I access both display_order fields from the different tables, I would like to list both.
__________________
Thanks
Jim M

"Lord, help me to become the person my dog thinks I am" - Dawn Ewing
"If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

www.huskyzone.com -- Woodland Siberians
musher is offline   Reply With Quote
Old 08-27-2006, 12:51 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
What you do is give the columns alias names in your select. As in, "SELECT a.display_order as content_order, b.display_order as menu_order". Then in your associative array the index names come out as "content_order" and "menu_order".

This is also handy for selecting formatted data, like "SELECT date_format(start_date, '%y %m %d') as startdate". Without the alias, the index name becomes "date_format(start_date, '%y %m %d')"... nasty stuff!
Fumigator is offline   Reply With Quote
Old 08-27-2006, 09:05 PM   PM User | #3
musher
Regular Coder

 
musher's Avatar
 
Join Date: Jan 2005
Location: Minnesota
Posts: 203
Thanks: 0
Thanked 0 Times in 0 Posts
musher is an unknown quantity at this point
Fumigator, Thanks much you've been a hugh help the last couple of days.
__________________
Thanks
Jim M

"Lord, help me to become the person my dog thinks I am" - Dawn Ewing
"If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

www.huskyzone.com -- Woodland Siberians
musher is offline   Reply With Quote
Old 08-27-2006, 10:28 PM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You're welcome
Fumigator 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 09:15 PM.


Advertisement
Log in to turn off these ads.