Php script for make TAG Cloud for more interactive website

TAG Cloud. That’s show our TAG or others for make our website more interactive. I use this for my classified website. I want to display TAG of Ads’ TAG. After search at google, I use this script and I think this script good.

This for Style. Place it between <head> and </head> of our website.


You can change/edit the style for your own purpose. You can set the color, border if you want or other else.

And this is example for using tag cloud. Example display TAG for categories

< ?php /** this is our array of tags * We feed this array of tags and links the tagCloud * class method createTagCloud */ $tags = array( array('weight' =>40, 'tagname' =>'Art and Entertainment', 'url'=>'http://obamatruthsquad.com/category/art-and-entertainment'), array('weight' =>12, 'tagname' =>'kloxo server', 'url'=>'http://obamatruthsquad.com/category/internet/kloxo-server'), array('weight' =>15, 'tagname' =>'BUSINESS', 'url'=>'http://obamatruthsquad.com/category/business'), array('weight' =>10, 'tagname' =>'domain', 'url'=>'http://obamatruthsquad.com/category/internet/domain'), ); /*** create a new tag cloud object ***/ $tagCloud = new tagCloud($tags); echo $tagCloud -> displayTagCloud(); ?>
< ?php class tagCloud{ /*** the array of tags ***/ private $tagsArray; public function __construct($tags){ /*** set a few properties ***/ $this->tagsArray = $tags; } /** * * Display tag cloud * * @access public * * @return string * */ public function displayTagCloud(){ $ret = ''; shuffle($this->tagsArray); foreach($this->tagsArray as $tag) { $ret.=''.$tag['tagname'].''."\n"; } return $ret; } } /*** end of class ***/ ?>

Hope this usefull

Incoming search terms for the article:

php interactive tag cloud, building interactive cloud with php, search site create tag cloud php, tag cloud php script, tag cloud php script for website, tag cloud PHP script use URL, tag cloud script, tag cloud script for websites, tag cloud script in php, tag cloud script in php for showing different location

Make file connection Mysql Database

We can first make php file conn.php for set connection to our mysql database.

<?php
/* MySQL configuration */

//enter your MySQL database host name, often it is not necessary to edit this line
$db_host = "localhost";

//enter your MySQL database username
$db_username = "username";

//enter your MySQL database password
$db_password = "password";

//enter your MySQL database name
$db_name = "dbname";

/ ----- do not edit below ------
//conect to db
$conn = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error());
$db = mysql_select_db($db_name, $conn) or die(mysql_error());

//start session
session_start();

//get the time
$t = time();

?>

you can copy and paste that code as file : conn.php

Incoming search terms for the article:

makefile db connection

Php script for change enter to <br>

At textarea I always want to make enter(new paragraph to become <br>.

Example:

at form at textarea , I input (bold only for point only not for input result):

Hold

Copy

Paste

After I submit, result for textarea always like this for preview : HoldCopyPaste

So I find this for change enter to <br>

ex :

<form method="post">
<p>
<textarea name="tes"></textarea>
</p>
<p><input type="submit" value="submit" /></p>
</form>

At Submit form proccess, place this :

$tes= ltrim($_POST[tes]);
$tes=eregi_replace("<","&lt;",$tes);
$tes=eregi_replace(">","&gt;",$tes);
$hasil=eregi_replace(chr(13),"<br>",$tes);
echo"$hasil";

At browser, we input at textarea like this :

Hold

Copy

Paste

And result we will get also same like above.

Incoming search terms for the article:

submit form enter php