I have MySQL table called Files which has file_id column and file_type column (and also other columns that are not relevant to the question).
I would like to get all file_ids of all picture files (i.e. file_type='picture').
I do the query like this:
$pictures_query = mysql_query("SELECT file_id FROM Files WHERE file_type='picture')
and now the question is: how would I put all picture file_ids into an array ?
I thought to do this like that:
$pictures_ids = array();
while ($row = mysql_fetch_row($pictures_query)) {
$pictures_ids[] = $row[0];
}
Does the loop really necessary, or there is a better way to do this ?
You can use
GROUP_CONCATwithexplodeto avoid looping: