Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

array of containing each unique value

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

array of containing each unique value

Postby kohaleraxa » Sun May 19, 2013 1:15 pm

How should I write PHP to build an array of containing each unique value in a table column?

Lets say the table headings are "code", "first_name", "last_name"
Data in the table "1" "Bob" "Smith", "2" "Tom" "Jones", "3" "David" "Green".

So I want a MySQL query that returns
$variable = array(1, 2, 3)

How can I do that?
____________________
checkless checking account ~ checking accounts online ~ checking account online
kohaleraxa
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Mar 30, 2013 2:06 am

Re: array of containing each unique value

Postby johnmacd » Thu Jun 13, 2013 11:24 pm

select code,first_name,last_name from table name;
johnmacd
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 12, 2013 9:30 pm

Re: array of containing each unique value

Postby johnj » Sat Jun 15, 2013 4:20 am

please read about the built-in function called mysql_fetch_array
http://php.net/manual/en/function.mysql-fetch-array.php
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.