dpabla Posted January 6, 2007 Share Posted January 6, 2007 hey whats up everyone...happy new years..Question: A user clicks on a particular item on the webpage named Apples which ID = 2- the ID has been passed onto the next page. The newpage.php?id=2 should THAN display the Product name on the page...based on the the logic that the _Get variable would be set to "2" and a JOIN statement would be "ok we got a number 2 from the subcategory table, lets get that same number 2 and look up the product name which is Apple and output the name to the screen. My table is structured below....Table named Products subcategory_id Product Name--------------- --------------2 AppleTable #2 named: Subcategorysubcategory_id ---------------2 My code that I am stumped on:[code]<?php$result = mysql_query("select subcategory_id, subcategory_name from products,subcategoryWHERE products.subcategory_id=subcategory.subcategory_id subcategory_id= {$_GET['sub_id']}");[/code]Thanks so much for your help...the part I am stuck on is this: subcategory_id= {$_GET['sub_id']}" <--------- thats my logical reasoning that the Select query needs to "GET" the variable "2" so that the subcategory ID's are being matched from both tables to output "APPLES" Link to comment https://forums.phpfreaks.com/topic/33038-php-joinquestion/ Share on other sites More sharing options...
Eugene Posted January 6, 2007 Share Posted January 6, 2007 SELECT products.subcatergory_id, products.subcategory_name FROM productsJOIN subcategory ON products.subcategory_id = subcategory.subcategory_idWHERE products.subdcategory_id = '{$_GET['sub_id']}'Hope that helps. Link to comment https://forums.phpfreaks.com/topic/33038-php-joinquestion/#findComment-153923 Share on other sites More sharing options...
kateland Posted January 6, 2007 Share Posted January 6, 2007 I ran into that earlier...and you know what I did? Since I was doing everything GET anyway, and the SQL had already been done, I just passed the "product name" over along with the ID :) Link to comment https://forums.phpfreaks.com/topic/33038-php-joinquestion/#findComment-153925 Share on other sites More sharing options...
dpabla Posted January 6, 2007 Author Share Posted January 6, 2007 Thanks for your help.... Link to comment https://forums.phpfreaks.com/topic/33038-php-joinquestion/#findComment-154303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.