_user
01-31-2012, 10:39 PM
I have db with a column that contains word tags separated with ","
I populate pages with data from db and when I echo the tags I wan't to echo as links that make a search for that word.
how can I do that?
thank you
>ssp-cdr<
01-31-2012, 11:06 PM
This will get you started. It assumes that the tags are separated by a comma with no space.
<?
$tags = 'apple,banana,orange,kiwi'
$tags = explode(',', $tags);
foreach ($tags as $t) { ?><a href="?tag=<?=urlEncode($t)?>"><?=htmlSpecialChars($t)?></a><br /><? }
?>
BluePanther
02-01-2012, 12:18 AM
This will get you started. It assumes that the tags are separated by a comma with no space.
<?
$tags = 'apple,banana,orange,kiwi'
$tags = explode(',', $tags);
foreach ($tags as $t) { ?><a href="?tag=<?=urlEncode($t)?>"><?=htmlSpecialChars($t)?></a><br /><? }
?>
Spaces wouldn't be a problem. You could either array_map() tags with the trim() function, or trim $t every time round.