/    Sign up×
Community /Pin to ProfileBookmark

meta tag system for a blog

i have a ‘meta’ field in my blog which when i enter a blog i enter key words ‘rant php mysql’ etc… using a space as an identifier. currently i i haven’t been doing anything with this data. but now i want to split the words up and display them on the page in a list.

sounds easy…

but heres the bit i cant get my head round i don’t want duplicate data in the list.

i.e. more than one of my blogs will contain PHP or MYSQL but how would i stop these from looping again

[code=php]
$query = “SELECT meta FROM `blog`”;
$result = mysql_query($query) or die();
while ($row = mysql_fetch_assoc($result))
{
some function???
{
echo ‘<li><a href=”/blog/’.$meta.'”>’.$meta.'</a></li>’;
}
}
[/code]

thanks in advance

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bokehNov 04.2006 — [code=php]$query = "SELECT meta FROM blog";
$result = mysql_query($query) or die(mysql_error());
$meta_words = array();
if(mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_assoc($result))
{
if(preg_match_all('/w{3,}/', $row['meta'], $matches))
{
foreach($matches[0] as $meta_word)
{
$meta_words[$meta_word] = $meta_word;
}
}
}
}
sort($meta_words);
foreach($meta_words as $meta_word)
{
echo '<li><a href="/blog/'.$meta_word.'">'.$meta_word.'</a></li>';
}[/code]
Copy linkTweet thisAlerts:
@knowjauthorNov 04.2006 — thanks bokeh ?
Copy linkTweet thisAlerts:
@bokehNov 04.2006 — By the way that is case sensitive, although it could easily be changed!!!
Copy linkTweet thisAlerts:
@knowjauthorNov 04.2006 — its only pulling information from the database. case sensitive would only become an issue if the users were entering data
×

Success!

Help @knowj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...