Kinda confused by the online tutorials on this one.
I have a table that contains id's of entries in a given category.Table "categories"id | category11 | red9 | red8 | red22 | blue5 | blue7 | greenLet's say I use this:$query = "SELECT id FROM categories WHERE category='red'";$result = mysql_query($query);I need an array that would be in this format:$ids = array("11","9","8");How do I do the conversion? Using the result from the selection?I need the variable $ids to be in that format for a function I'm using but can't seem to get the 11,9, and 8 like that. Any help?
The output of that is only the first id with the category red. I only get 11 in return.
No Spectre, that will only give you the columns of $r for the first element in the mysql result. You have to repeat the mysql_fetch part for every element in the result. Easiest way of doing so is with a while loop:
Exactly what aeron said.
Thanks aeron. That worked perfectly!
w3schools?
php.net? :P
a tutorial is not worth the advice of a person whose experienced. I can ask questions about something when a person shows me how to do something whereas tutorials are usually vague and don't respond when you ask them something. Typical responses post 8 and 9.