sandrulis Posted July 21, 2010 Report Share Posted July 21, 2010 Veidojot tagu mākoni, man neizdodas apvienot vārdus. ja ir vienādi vardi viņi vienkārši atkārtojās, nevis apvienojas. izmēģināju vis kaut ko bet nekādīgi nesanāk. nevarat izlīdzēt? Šis ir kods ko izmantoju kā pamatu. $result=mysql_query("SELECT * FROM topics"); while($row = mysql_fetch_array($result)) { $tag = explode(" ", $row['tags']); $skaits = count($tag); for ($i = 0; $i < $skaits; ++$i) { $tagi = $tag[$i]; print $tagi.', '; } } Zinu ka man sanāktu ja mācētu šādi, lai parādās $randomWords = array($tags1, $tags2, $tags3, $tags4, $tags5), bet man viņš uzmet tikai pēdējo :(. kad lietoju šādu kodu: $result=mysql_query("SELECT * FROM topics"); while($row = mysql_fetch_array($result)) { $tag = explode(" ", $row['tags']); $skaits = count($tag); for ($i = 0; $i < $skaits; ++$i) { $tagi = $tag[$i]; $randomWords = array($tags); } } Lūdzu palīdziet man izveidot, lai ir šādi: $randomWords = array($tags1, $tags2, $tags3, ..., $tagsN); vai arī kādu citu piedāvājumu :) Paldies Quote Link to comment Share on other sites More sharing options...
101111 Posted July 21, 2010 Report Share Posted July 21, 2010 $randomWords = array(); $result=mysql_query("SELECT * FROM topics"); while($row = mysql_fetch_array($result)) { $tag = explode(" ", $row['tags']); $randomWords = array_merge($randomWords, $tag); } print_r($randomWords); Tā var salikt masīvā visus tagus Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted July 21, 2010 Report Share Posted July 21, 2010 Reku pats vienkaarshaakais variants $tags = array(); $result = mysql_query('SELECT tags FROM topics'); while($row = mysql_fetch_assoc($result)) { $article_tags = explode(' ', $row['tags']); $tags = array_merge($tags, $article_tags); } $tags = array_unique($tags); echo '<pre>' . print_r($tags, 1) . '</pre>'; Labaak, gan, protams, buutu glabaat tagus atsevishkjaa tabulaa un join'ot tos kopaa ar rakstu izmantojot tresho tabulu articles - id - title - text tags - id - tag taginizer - article_id - tag_id Quote Link to comment Share on other sites More sharing options...
sandrulis Posted July 21, 2010 Author Report Share Posted July 21, 2010 a ko darīt ja taga vārds satur mīkstinājuma zīmes? vienkārši vārds rādās ar simboliem Quote Link to comment Share on other sites More sharing options...
mixis Posted July 21, 2010 Report Share Posted July 21, 2010 Kā tu to vārdu izvadi? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.