Jump to content

[SOLVED] query HELP...


tauchai83

Recommended Posts

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

Link to comment
Share on other sites

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 />";

}

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.:)

Link to comment
Share on other sites

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.