FlashDance
09-30-2011, 10:23 AM
Does anyone know how I can select (all) from a specific field, in this case - .category"?
Something like:
select id from products where category = *
I am using it for:
if ($_POST['category'] == "(Any)") {
$_POST['category'] = "*";
... then I'd be using:
select id from products where category = ".$_POST['category']."
thesam101
09-30-2011, 10:35 AM
Hi FlashDance
no need for the where clause.
the query:
select id from products
by itself will return all the IDs. :thumbsup:
FlashDance
09-30-2011, 10:39 AM
Hi,
This code won't help because it is not basing the id's off category.
abduraooft
09-30-2011, 11:02 AM
Something like:
select id from products where category = *
select id from products
... then I'd be using:
select id from products where category = ".$_POST['category']."
Why would you need to do that?
FlashDance
09-30-2011, 11:06 AM
Its too complex to explain.
... so do you know how it can be done?
FlashDance
09-30-2011, 12:03 PM
select id from products
Hi,
This code won't help because it is not basing the id's off category......
FlashDance
09-30-2011, 12:08 PM
I've been asking all around the internet if anyone know how I can select (all) from a specific field (in this case - category), but no one seems to be able to give me a straight answer, its either an answer that does not address my question which was given based on an incorrect assumption that they know what I am trying to do, or some coding preacher trying telling me to code this way, and when I say I don't wish to do that because I feel comfortable my way, the person arrogantly turns around and says "well, I'm not helping you!".
People really need to learn how to have a no-bull **** conversation, instead of kicking **** into peoples faces.
This isn't directed at anyone on codingforums.com... am just saying how hard it is to get a simple answer when asking for help from computer programmers. :)
djm0219
09-30-2011, 12:16 PM
Based on your original post the answer provided in post number 2 is correct. If you are intent on using a WHERE clause, as shown in the last example of your original post, change it to:
SELECT `id` FROM `products` WHERE `category` LIKE '%'
That should get you all of the IDs regardless of their category which is what you appear to be asking for (the answer in post 2 should get you the same results).
FlashDance
09-30-2011, 12:38 PM
Dear djm0219,
I tried your code and got this:
http://i52.tinypic.com/107m7tg.png
FlashDance
09-30-2011, 12:43 PM
Ok, your code was actually correct. Appology!
SOMEHOW "mysql> " got in the code!!
FlashDance
09-30-2011, 12:45 PM
I am trying to thank you, but there is an error due to me using a web proxy to access this site. I will login directly later on when my connection throttle to 72kbps has been lifted.
Thanks in the mean time! :)
guelphdad
09-30-2011, 09:33 PM
I've been asking all around the internet if anyone know how I can select (all) from a specific field (in this case - category), but no one seems to be able to give me a straight answer, its either an answer that does not address my question which was given based on an incorrect assumption that they know what I am trying to do, or some coding preacher trying telling me to code this way, and when I say I don't wish to do that because I feel comfortable my way, the person arrogantly turns around and says "well, I'm not helping you!".
The problem though could be the way you are asking a question or the fact that you come to the forum(s) with a specific answer in mind and you aren't willing to listen to other people's ideas.
Remember you may be explaining your problem in a way that makes sense to you, but it may be that you are not explaining it a straight forward as you believe you are and THAT may contribute to the problem as well.