Select all tags separated by "," from the entire table

0
id | tags
1  | tag1,tag2,tag3
2  | tag1,tag2,tag3

In the db there is the column "tags" where it is "tag1, tag2, tag3 ..." I need to show all the separated tags, however it only shows the one of the first record, I would like to get everyone tags, how do I?

 $tags =  explode(',', $tags_row);

 foreach ($tags as $item) { 
   echo "< href='#'>$item</a> "; 
 }
    
asked by anonymous 10.05.2017 / 16:47

1 answer

2

There are several ways to solve the problem, here is an example:

$tags_row = 'tag1, tag2, tag3';

$tags =  explode(',', $tags_row);

foreach ($tags as $item) { 
 echo "<href='#'>{$item}</a><br>"; 
}

Your logic is correct, to print variables in PHP using "" double quotes in the echo you should use {$ variable} for php to escape the quotation marks.     

10.05.2017 / 18:34