gabael Posted March 18, 2014 Share Posted March 18, 2014 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. Link to comment https://forums.phpfreaks.com/topic/287051-select-value-from-table-and-use-it-as-another-value-from-same-table/ Share on other sites More sharing options...
gristoi Posted March 18, 2014 Share Posted March 18, 2014 firstly, how is id 1 relating to anything? you need to look at how you are structuring your tables Link to comment https://forums.phpfreaks.com/topic/287051-select-value-from-table-and-use-it-as-another-value-from-same-table/#findComment-1472982 Share on other sites More sharing options...
gabael Posted March 18, 2014 Author Share Posted March 18, 2014 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 ??? Link to comment https://forums.phpfreaks.com/topic/287051-select-value-from-table-and-use-it-as-another-value-from-same-table/#findComment-1472983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.