hello ! can any one help me with this script i want make tag cloud in my home page so i take this script from http://www.scriptplayground.com/tutorials/php/Tag-Cloud/ fierst i amke a new databse and anclud this and copy all this script to empty php page just a change the information about data base <?php function get_tag_data() { mysql_connect('xxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxx'); mysql_select_db('xxxxxxxxxxx'); $result = mysql_query("SELECT * FROM tags GROUP BY tag ORDER BY count DESC"); while($row = mysql_fetch_array($result)) { $arr[$row['tag']] = $row['count']; } ksort($arr); return $arr; } ?> <style type="text/css"> .tag_cloud { padding: 3px; text-decoration: none; } .tag_cloud:link { color: #81d601; } .tag_cloud:visited { color: #019c05; } .tag_cloud:hover { color: #ffffff; background: #69da03; } .tag_cloud:active { color: #ffffff; background: #ACFC65; } </style> <?php function get_tag_cloud(). { ... }; // Default font sizes $min_font_size = 12; $max_font_size = 30; // Pull in tag data $tags = get_tag_data(); $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(); // create an array to hold tag code foreach ($tags as $tag => <p>$count) { $size = $min_font_size + ($count - $minimum_count) * ($max_font_size - $min_font_size) / $spread; $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" href="http://www.google.com/search?q=' . $tag . '" title="\'' . $tag . '\' returned a count of ' . $count . '">' . htmlspecialchars(stripslashes($tag)) . '</a>'; } $cloud_html = join("\n", $cloud_tags) . "\n"; return $cloud_html;</p> ?> <body><h3>Sample Tag Cloud results</h3> <div id="wrapper" <!-- BEGIN Tag Cloud --> <?php print get_tag_cloud(); ?> <!-- END Tag Cloud --> </div> PHP: but there is nothig he show me this error Parse error: parse error, unexpected '.', expecting '{' in /homepages/3/d192671145/htdocs/DDL/tag.php on line 22 PHP: can any one help me with that please i test it like in the same page if he work i said i will move that script to my home page <body><h3>Sample Tag Cloud results</h3> <div id="wrapper" <!-- BEGIN Tag Cloud --> <?php print get_tag_cloud(); ?> <!-- END Tag Cloud --> </div> PHP: can any one help me with that
It's poorly explained on this website, but where the function is marked, it's just supposed to start there. It should be closed later though. Try this. (Untested) <?php function get_tag_data() { mysql_connect('xxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxx'); mysql_select_db('xxxxxxxxxxx'); $result = mysql_query("SELECT * FROM tags GROUP BY tag ORDER BY count DESC"); while($row = mysql_fetch_array($result)) { $arr[$row['tag']] = $row['count']; } ksort($arr); return $arr; } ?> <style type="text/css"> .tag_cloud { padding: 3px; text-decoration: none; } .tag_cloud:link { color: #81d601; } .tag_cloud:visited { color: #019c05; } .tag_cloud:hover { color: #ffffff; background: #69da03; } .tag_cloud:active { color: #ffffff; background: #ACFC65; } </style> <?php function get_tag_cloud() { // Default font sizes $min_font_size = 12; $max_font_size = 30; // Pull in tag data $tags = get_tag_data(); $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(); // create an array to hold tag code foreach ($tags as $tag => $count) { $size = $min_font_size + ($count - $minimum_count) * ($max_font_size - $min_font_size) / $spread; $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" href="http://www.google.com/search?q=' . $tag . '" title="\'' . $tag . '\' returned a count of ' . $count . '">' . htmlspecialchars(stripslashes($tag)) . '</a>'; } $cloud_html = join("\n", $cloud_tags) . "\n"; return $cloud_html; } ?> <body><h3>Sample Tag Cloud results</h3> <div id="wrapper" <!-- BEGIN Tag Cloud --> <?php print get_tag_cloud(); ?> <!-- END Tag Cloud --> </div> PHP:
thanks you for replay me tanks your script is work but hi show just that Sample Tag Cloud results whay the tag dont showup
what i did is just what i right here this is the sql table is like this CREATE TABLE tags ( id int(11) NOT NULL, tag varchar(100) NOT NULL, count int(11) NOT NULL DEFAULT '0' ); PHP: and the page tag.php i just put this <?php function get_tag_data() { mysql_connect('xxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxx'); mysql_select_db('xxxxxxxxxxx'); $result = mysql_query("SELECT * FROM tags GROUP BY tag ORDER BY count DESC"); while($row = mysql_fetch_array($result)) { $arr[$row['tag']] = $row['count']; } ksort($arr); return $arr; } ?> <style type="text/css"> .tag_cloud { padding: 3px; text-decoration: none; } .tag_cloud:link { color: #81d601; } .tag_cloud:visited { color: #019c05; } .tag_cloud:hover { color: #ffffff; background: #69da03; } .tag_cloud:active { color: #ffffff; background: #ACFC65; } </style> <?php function get_tag_cloud() { // Default font sizes $min_font_size = 12; $max_font_size = 30; // Pull in tag data $tags = get_tag_data(); $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(); // create an array to hold tag code foreach ($tags as $tag => $count) { $size = $min_font_size + ($count - $minimum_count) * ($max_font_size - $min_font_size) / $spread; $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' . '" class="tag_cloud" href="http://www.google.com/search?q=' . $tag . '" title="\'' . $tag . '\' returned a count of ' . $count . '">' . htmlspecialchars(stripslashes($tag)) . '</a>'; } $cloud_html = join("\n", $cloud_tags) . "\n"; return $cloud_html; } ?> <body><h3>Sample Tag Cloud results</h3> <div id="wrapper" <!-- BEGIN Tag Cloud --> <?php print get_tag_cloud(); ?> <!-- END Tag Cloud --> </div> PHP: thats it this is all i did
Okay, and now you're wondering why no tags appear? You have to add them manually to the database. This script doesn't invent tags. This script is meant to have a purpose. It's not meant to display random words on your website to make it look web 2.0'ish. Do you have a blog or something that could use tags in a meaningful way? Usually tags relate to an article, post, or just a page on your website. You have to know what you want to do before you start using random scripts.
i have a web site in php what i want before is to make for exemple whene visitor he search in the site that word he appear like recent search and i dont know verymuch in php so i foundout this tag i hope to make it like that most recent search apear in tag
no i have search engine in my site and the recent search whene he search from my search engine not from google
I will need your code then, if you want me to help you to insert the search keywords into your tags table.
Place this in "search.php": if (isset($_POST['q'])) { $keywords = preg_split('/[\s,]+/', $_POST['q'], -1, PREG_SPLIT_NO_EMPTY); foreach (array_unique($keywords) AS $keyword) { $keyword = mysql_real_escape_string(trim($keyword)); if (strlen($keyword) < 2) { continue; } mysql_query("UPDATE tags SET count = (count + 1) WHERE tag = '". $keyword ."' LIMIT 1") OR die(mysql_error()); if (!mysql_affected_rows()) { mysql_query("INSERT INTO tags (tag, count) VALUES ('". $keyword ."', 1)") OR die(mysql_error()); } } } PHP: Untested...
he give this related to them. Table 'xxxxxxx.tags' doesn't exist becose the tag table i creat in other database i have to creat another in database of the site
Or you can change the database by using: mysql_select_db('db_name') OR die(mysql_error()); PHP: If that doesn't work, try creating the table in the database you're actually using.
he dont work dont show anything i move out the data base to the site and whene i search he dont show nothing what exacler i did becouse the recent search is in the footer of the page so the script you give me i just add in fierst <?php and last ?> and past it in the footer of the page i tray to search something but there is nothing inrecent search
LIKE I SAID HE DONT SHOWS THE RESULTA WITH THAT CODE THE CODE WITH database he work fine but this he dont show nothing
This code doesn't show anything, it's not supposed to. Use your other code: http://forums.digitalpoint.com/showpost.php?p=3106694&postcount=5 This will display the tags if they're in the database.
i did it i use it this code and delete this from the code becose you give me another in the head but he show me this error