alex_funky_dj Posted September 15, 2007 Share Posted September 15, 2007 Hello, I've 2 tables with the following structure : Table 1 name : categories Fields : id, code, name. Table 2 name : Products Fields : id, category_id, code, name and here's MySQL query : $query="SELECT * FROM products INNER JOIN categories ON products.categpry_id = categories.id"; $result = mysql_query($query); $row = mysql_fetch_array($result); Now, I've the problem with "echo ()" !! when I make : echo $row[name]; it shows the name of product, how can I show the category name ?? I tried echo $row[categories.name]; but I'm having errors !! so how can I handle this ?? THANK YOU FOR YOUR TIME ! Quote Link to comment https://forums.phpfreaks.com/topic/69451-solved-showing-data-from-2-joine-tables/ Share on other sites More sharing options...
watthehell Posted September 15, 2007 Share Posted September 15, 2007 Try running this code in PHP My Admin and see the result... how the fields are displayed then you can assign by no. i.e. <?php echo $row[0]; echo $row[1]; ?> like this Quote Link to comment https://forums.phpfreaks.com/topic/69451-solved-showing-data-from-2-joine-tables/#findComment-348961 Share on other sites More sharing options...
alex_funky_dj Posted September 15, 2007 Author Share Posted September 15, 2007 thanks a lot for ur fast reply, it works fine with numbers, but can't it be handled with names :$ !! Quote Link to comment https://forums.phpfreaks.com/topic/69451-solved-showing-data-from-2-joine-tables/#findComment-348963 Share on other sites More sharing options...
watthehell Posted September 15, 2007 Share Posted September 15, 2007 Yes if you use names then there will be two results for $row['name'], so it will be hard to fetch the one you want, I guess there wont be problem with number though... Quote Link to comment https://forums.phpfreaks.com/topic/69451-solved-showing-data-from-2-joine-tables/#findComment-348965 Share on other sites More sharing options...
alex_funky_dj Posted September 15, 2007 Author Share Posted September 15, 2007 Thanks a alot, that learned me to make the fields name more unique next time. thanks again -Mahmoud Quote Link to comment https://forums.phpfreaks.com/topic/69451-solved-showing-data-from-2-joine-tables/#findComment-348968 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.