Note that there are some explanatory texts on larger screens.

plurals
  1. POPhp tags display
    primarykey
    data
    text
    <p>There are 4 tables used for storing tags:</p> <pre><code>tagovi, tagovi_vijesti, tagovi_blogovi, tagovi_dogadjanja </code></pre> <p>Structure od table <code>tagovi</code>:</p> <pre><code>id - name </code></pre> <p>Structure of table <code>tagovi_vijesti</code>:</p> <pre><code>id - vijesti_id - tag_id </code></pre> <p>The same is for other two tables.</p> <p>On main page I display tags from all three tables this way:</p> <pre><code>$sql = "SELECT T.id AS id, T.name AS tag, TV.id AS tag_vijest_id, TD.id AS tag_dogadjanje_id, TB.id AS tag_blog_id, COUNT(*) ponavljanje FROM tagovi AS T LEFT JOIN tagovi_vijesti AS TV ON T.id = TV.tag_id LEFT JOIN tagovi_dogadjanja AS TD ON T.id = TD.tag_id LEFT JOIN tagovi_blogovi AS TB ON T.id = TB.tag_id WHERE TV.id IS NOT NULL GROUP BY id ORDER BY id DESC LIMIT 35"; $sql_result = mysql_query($sql,$connect) or die("Upit nije izvrsen"); while ($row = mysql_fetch_array($sql_result)){ $tag_id = $row["id"]; $tag_url = $row["tag"]; $tag = preg_replace('/-/', ' ', $tag_url); $tag_ponavljanje = $row["ponavljanje"]; if($tag_ponavljanje &gt;= 10 &amp;&amp; $tag_ponavljanje &lt; 20) $fontSize = "14px"; elseif($tag_ponavljanje &gt;= 20 &amp;&amp; $tag_ponavljanje &lt; 30) $fontSize = "16px"; elseif($tag_ponavljanje &gt;= 30 &amp;&amp; $tag_ponavljanje &lt; 40) $fontSize = "18px"; elseif($tag_ponavljanje &gt;= 40 &amp;&amp; $tag_ponavljanje &lt; 60) $fontSize = "20px"; elseif($tag_ponavljanje &gt;= 60) $fontSize = "24px"; else $fontSize = "12px"; echo " &amp;nbsp; &lt;a href = \"$ispisi_link/tag/$tag_url\" style=\"font-size: $fontSize;\"&gt;$tag&lt;/a&gt; &amp;nbsp; "; } </code></pre> <p>But I don't think that this is the perfect way to do it because tags are sorted by id and then all those old tags will never be displayed again because results are sorted by id. What kind of display (query) do you use? What would you advise me about displaying tags? Is it better to sort them by number of repeating of each tag (in my table repeating is called "ponavljanje")? If I use this way then I'm bit afraid that there will be tags that will be repeated in most of content and new one will never be displayed on main page. Or should I maybe use two queries, one for new tags and one for those who are mostly used?</p> <p>Thanks, Ile</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload