tauchai83 Posted February 8, 2007 Share Posted February 8, 2007 I have one table that contain 2 primary key, pd_id and od_id and additional column od_qty (order quantity). i'm trying to do a query that can retrive the total of the order quantity for each product. here is my code: $total = mysql_query("SELECT SUM(od_qty) AS cnt FROM order_item WHERE pd_id=$pd_id "); it returns Resource id #4 which i Don't know what does it means. Can anyone help me? thanks! ps: where is si fu? haha Quote Link to comment https://forums.phpfreaks.com/topic/37596-solved-query-help/ Share on other sites More sharing options...
hvle Posted February 8, 2007 Share Posted February 8, 2007 LOL, this question is as silly as it is funny. $total is a resultset, result returned from mysql. You can not echo it. You need a routine. while ($row = mysql_fetch_assoc($total)) // $row is an array contain a row in your table { echo $row['cnt'] . "<br />"; } Quote Link to comment https://forums.phpfreaks.com/topic/37596-solved-query-help/#findComment-179836 Share on other sites More sharing options...
tauchai83 Posted February 8, 2007 Author Share Posted February 8, 2007 you know the word "respect"? Autralian is like that? If you don want to help, is ok...i can ask others...and do not pretend you are proficient in everthing. I do not feel it silly as the learning process is continuing. by the way, i never say i echo total straght away...LOL...maybe you should evaluate yourself. Respect is what you will get in return. respect others! Quote Link to comment https://forums.phpfreaks.com/topic/37596-solved-query-help/#findComment-179852 Share on other sites More sharing options...
hvle Posted February 8, 2007 Share Posted February 8, 2007 wow a sensitive little kid, It's just a friendly laugh. I don't mean any disrespect really, sorry. k mate? we cool? really, it's just a friendly laugh, that's all. I laugh all the time, don't be too serious. Quote Link to comment https://forums.phpfreaks.com/topic/37596-solved-query-help/#findComment-179860 Share on other sites More sharing options...
fenway Posted February 8, 2007 Share Posted February 8, 2007 I would recommend prefixing the variable used to store mysql_query() return values with "rs" to make it explicit, e.g. rsTotal. I'm a big proponent of variable prefixing (though not of Hungarian/Polish notation, which is horrible). Quote Link to comment https://forums.phpfreaks.com/topic/37596-solved-query-help/#findComment-179945 Share on other sites More sharing options...
tauchai83 Posted February 9, 2007 Author Share Posted February 9, 2007 Ok...thanks Fenway, I've solved this problem. Thanks a lot for your advise. I will use prefix variable for easier understanding of my code. To Hvle, well, forum could not see your face that you were making joke, haha, but I don't have any hard feeling about that. Misunderstanding always happen. So, let's forget abou it. Quote Link to comment https://forums.phpfreaks.com/topic/37596-solved-query-help/#findComment-180533 Share on other sites More sharing options...
hvle Posted February 9, 2007 Share Posted February 9, 2007 LOL, *shake hand* Quote Link to comment https://forums.phpfreaks.com/topic/37596-solved-query-help/#findComment-180535 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.