Jump to content

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.

Edited by gabael

id 1 from URL is relating to submenus id 1.

I need to grab that ID somehow transfrom it to value-> menus_id and than do some query WHERE menus.id = submenus.menus_id.

Is this possible to do ???

Edited by gabael
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.