select value in array

2

Good,

Looking at this query:

$sql = mysql_query("select A, B, C, D from table");
$row_sql = mysql_fetch_assoc($sql);

I want to get column A and put all values in an array:

$var = array('value1','value2','value3','value4');

How best to do this?

Thank you.

    
asked by anonymous 12.08.2015 / 15:46

1 answer

2

With while .

$sql = mysql_query("select A, B, C, D from table");

while($res = mysql_fetch_assoc($sql)){
    $arrData[] = $res['A'];
}

echo '<pre>';
print_r($arrData);
echo '</pre>'
    
12.08.2015 / 15:49