Jump to content

Select value from table and use it as another value from same table.


gabael

Recommended Posts

Hi guys.

I'm strunggling with one mysql query. Please help. The situation is following:

I have 2 tables:

+========= MENUS ===========+

| ID   |   menu_name  | menu_link      |

| 21  |  home              | home.php      |

| 22  |  products         | products.php |

| 23  | about               | about.php      |

+============================+

 

+============== SUBMENUS ==============+

| ID | menus_id |  submenu_name  | submenu_link  |

| 1  |   22           |      product 1        | product-1.php |

| 2  |   22           |      product 2        | product-2.php |

| 3  |   23           |      contacts          | contactas.php |

+=======================================+

 

 

my URL looks like www.domain.com/product-1.php?id=1

based on ID value from URL product-1.php?id=1 I need to display the Product 1 and Product 2

 

I tried something like this:

"SELECT menus.id, submenus.* FROM menus, submenus WHERE menus.id=submenus.menus_id"

 

but it gives me of course back everything from submenus.

How can I reduce result to show me only product 1 and product 2 based on ID from URL ????

 

Thanks for any help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.