I’m creating a tag system for website with PHP. I created 3 tables: one for Articles (table name:article, rows: id, title, alias), one for Tags (name:tag_content, rows:id, name, link) and one for assign tag for articles (name: tag_art, rows: id_tag, id_arty; for example: 4 articles, with different id, all with one id_tag equal 2). All scripts are done, so I can add the Articles, Tags, and assign Tags to Articles. I have also written a script for display the result-link:
$zmienna = "SELECT name, link FROM tag_content";
$result2 = mysql_query($zmienna);
echo $result2;
while($row=mysql_fetch_array($result2)){
echo "<a href='http://www.somelink.xx/tag/".$row['link']."'>".$row['name']."</a><br>";
}
And it shows all created links(tags).
1. Now i want to take not every tags but random from the database and display them (so it should be more natural). How to do it?
2. After clicking link/tag I want to display all articles with the same id_tag (assigned to one tag). How to do it?
Thx for help. If I didn’t put enought information (code etc.), let me know.
the query for random
SELECT column FROM table
ORDER BY RAND()
LIMIT 4
you can set the limit whatever you want
2.
create tag.php file:
?>