Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display text bigger according to how many times entered into a MySQL database using PHP and MySQL?
    primarykey
    data
    text
    <p>Okay, I have this script that should display the tags that are entered more times bigger and tags that are entered less smaller for a certain question. But for some reason it displays the last tag entered bigger and displays all the tags that where entered before it smaller like if it was counting down. I need to fix this problem.</p> <p>I hope I explained this right?</p> <p>Here is the MySQL tables.</p> <pre><code>CREATE TABLE questions_tags ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, tag_id INT UNSIGNED NOT NULL, users_questions_id INT UNSIGNED NOT NULL, PRIMARY KEY (id) ); CREATE TABLE tags ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, tag VARCHAR(255) NOT NULL, PRIMARY KEY (id) ); </code></pre> <p>Here is my PHP script.</p> <pre><code>&lt;?php $db_host = "localhost"; $db_user = "root"; $db_pass = ""; $db_name = "sitename"; mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($db_name); function tag_info() { $result = mysql_query("SELECT questions_tags.*, tags.* FROM questions_tags INNER JOIN tags ON tags.id = questions_tags.tag_id WHERE questions_tags.users_questions_id=3 ORDER BY users_questions_id DESC"); while($row = mysql_fetch_array($result)) { $arr[$row['tag']] = $row['id']; } ksort($arr); return $arr; } function tag_cloud() { $min_size = 10; $max_size = 30; $tags = tag_info(); $minimum_count = min(array_values($tags)); $maximum_count = max(array_values($tags)); $spread = $maximum_count - $minimum_count; if($spread == 0) { $spread = 1; } $cloud_html = ''; $cloud_tags = array(); foreach ($tags as $tag =&gt; $count) { $size = $min_size + ($count - $minimum_count) * ($max_size - $min_size) / $spread; $cloud_tags[] = '&lt;a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" href="http://www.example.com/tags/' . $tag .'/' . '" title="\'' . $tag . '\' returned a count of ' . $count . '"&gt;' . htmlspecialchars(stripslashes($tag)) . '&lt;/a&gt;'; } $cloud_html = join("\n", $cloud_tags) . "\n"; return $cloud_html; } ?&gt; &lt;div id="wrapper"&gt; &lt;?php print tag_cloud(); ?&gt; &lt;/div&gt; </code></pre>
    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.
 

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