PDA

View Full Version : php array and mysql help



lapubell
March 10th, 2008, 09:19 PM
a bit confused as to how to accomplish this. any help would be great.

I have a mysql database that is filled with a bunch of tables. for example:

| id | type | name | ...
| 1 | cat | mittens | ...
| 2 | cat | buttons | ...
| 3 | cat | cougar | ...
| 4 | dog | rover | ...
| 5 | cat | tabby cutie | ...
| 6 | bird | tweety | ...
| 7 | dog | kaninja | ...
...


so I know I need to use a loop to read the database info, but how would I build an array that holds the "type" column, without repeating the info? I don't want a cell for every row, but (for this example) just an array of ("cat", "dog", "bird").

Any ideas?

LaRoza
March 10th, 2008, 09:20 PM
Look at the DISTINCT option for SELECT statements in SQL. It sounds like it is what you want.

lapubell
March 10th, 2008, 09:22 PM
hmm... working on a not that friendly mysql server without command line access. any help looking into this through phpmyadmin or the sql command to get that info?

sorry for being a newb at sql... databases make my head spin sometimes...

lapubell
March 10th, 2008, 09:28 PM
google and LaRosa to the rescue! check this out if you have similiar questions.
http://www.webdevelopersnotes.com/tutorials/sql/online_mysql_guide_the_distinct_keyword.php3

mssever
March 11th, 2008, 02:49 AM
You can enter any query into phpMyAdmin and see the results. I actually tend to use phpMyAdmin instead of the CLI program, even though I have access to the CLI.