Reputation: 5025
So let's say this is the hierarchy of my database in MySQL.
Database: Example
Table: Test
Row 1
Column 1 ("one"): Whatever
Column 2 ("two"): Something
Column 3 ("three"): Test
Row 2
Column 1 ("one"): Blah
Column 2 ("two"): Testing
Column 3 ("three"): Yup
How can I return an array that has the values of the one
columns?
The array would look like this:
Array ( [0] => Whatever [1] => Blah )
Upvotes: 0
Views: 177
Reputation: 48630
$query = "SELECT column1 FROM test";
$result = mysql_query($query);
$numRows = mysql_num_rows($result); // should be 2
while($row = mysql_fetch_array($result)) {
$row[0]; // data from column
}
Upvotes: 1
Reputation: 14470
Might be issue with the spaces. If there are spaces in column name use back quotes e.g
select `Column 1` from tablename;
I am not sure your example depicts your actual problem :(
Upvotes: 1