/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Links from keywords

If I have keywords in a database, can I set up a script that will read the keywords in a database and turn it into a list of links?

I have a column called “Keywords” in my table, where I store keywords. Some rows have more than one keyword.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@SheldonOct 19.2006 — So other from asking this question in 3 threads, what are you trying to ask in this one?

You could use http://php.net/explode to split the keywords from the databse.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 19.2006 — So other from asking this question in 3 threads, what are you trying to ask in this one?[/QUOTE]

Repeating a question is generally a symptom of it not being answered.


Let's say we have a table here, with several keywords.

[CODE]
Row Keywords
----------------
1 html forum
2 video
3 furry forum
4 html
5 wrestling
6 furry flash
[/CODE]


The script would look through the "Keywords" column and say "Okay, row 1 has the keywords 'html' and 'forum'. Row 2 has 'video'. Row 3 has 'furry' and 'forum'. Row 4 has 'html', but I already have that keyword, so I will discard it. Row 5 has 'wrestling'. Row 6 has 'furry' and 'flash', but I already have 'furry', so I'll discard that keyword, and keep 'flash'.

It then sorts the keywords by alphabetical order:

[B]flash

forum

furry

html

video

wrestling[/B]


Using these, it sets up the links:
[code=html]<li><a href="index.php?keyword=flash">flash</a></li>
<li><a href="index.php?keyword=forum">forum</a></li>
<li><a href="index.php?keyword=furry">furry</a></li>
<li><a href="index.php?keyword=html">html</a></li>
<li><a href="index.php?keyword=video">video</a></li>
<li><a href="index.php?keyword=wrestling">wrestling</a></li>
[/code]


That's what I want.
Copy linkTweet thisAlerts:
@scousesheriffOct 19.2006 — Maybe something along the lines of this will help:

[code=php]
$sql = "select keywords from TABLE";
$result = mysql_query($sql);
$i = 0;

while($row = mysql_fetch_array($result){
$TempStrings = explode(" ", $row["keywords"]);
foreach($TempStrings as $key => $value){
$strings[$i] = $value;
$i++;
}
}
$strings = array_unique($strings); //removes duplicates
asort($strings);
echo "<ul>";
foreach($strings as $key => $value){
echo "<li><a href="index.php?keyword=".$value."">".$value."</a></li>";
}
echo "</ul>";
[/code]
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 19.2006 — Sorry, fixed all bugs
Copy linkTweet thisAlerts:
@scousesheriffOct 19.2006 — Have you definitely included the explode function in your code? Cant see what's wrong with the code I posted.

Any thoughts anyone?
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorOct 20.2006 — It was in the database. I had

html

forum

as a pair of keywords instead of

html forum
×

Success!

Help @Mr_Initial_Man 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.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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