umaxim
asked on
BLog tags
Hi i am making blog script for one website and i get a problem with making tags feature.
I try to make this kind of sql query
But if i have 2 tag in one article it make clone article and show it twice. So if it any way to group all tags using for example ",". Or is any way to do it better.
I try to make this kind of sql query
Select date,tag as tags, author, name, full_text, keywords, description, url, blog.id from blog RIGHT JOIN tags ON tags.blog = blog.id where ".$where." date <= DATE(NOW()) and `show` = '1' limit ".$page.",".$limit."
But if i have 2 tag in one article it make clone article and show it twice. So if it any way to group all tags using for example ",". Or is any way to do it better.
ASKER
I do not need to brake it on explode. I need to join them in mysql query so when i make query it give me all my blogs and all my tags with out making number of tags copy of blog.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You might want to consider "normalization" of the tags into a separate table. If you're not sure you understand what "normalization" means, make a Google search for "Should I Normalize My Database" and read the very interesting design ideas -- both pro and con -- about this subject.
Armed with that information your query may be able to use GROUP BY to limit the size of the results set.
Armed with that information your query may be able to use GROUP BY to limit the size of the results set.
date = 1/1/2000
tags = abc,123,zxy
author=mr bill
Then in your php script you can turn the tags field to an array and break it out with explode.
http://php.net/manual/en/f
$tags = tags;
var_dump( explode( ',', $tags ) );
result
(
[0] => string(5) "abc"
[1] => string(5) "123"
[2] => string(5) "xyz"
)
This is at least what I do in vb. I hope it translates. I am trying to learn php too.