<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BLUEice studios &#187; php percentage bar</title>
	<atom:link href="http://www.blueicestudios.com/tag/php-percentage-bar/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blueicestudios.com</link>
	<description>Solutions for Mixed Media &#38; Web Development.</description>
	<lastBuildDate>Sat, 08 May 2010 20:43:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Percentage Bar</title>
		<link>http://www.blueicestudios.com/php-percentage-bar/</link>
		<comments>http://www.blueicestudios.com/php-percentage-bar/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 23:32:28 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php percentage bar]]></category>

		<guid isPermaLink="false">http://www.blueicestudios.com/?p=14</guid>
		<description><![CDATA[
Source Files: DOWNLOAD
View working examples here: DEMO
MySQL Table, used for example.

CREATE TABLE IF NOT EXISTS `percent` (
`per_id` int(11) NOT NULL auto_increment,
`per_num` varchar(255) NOT NULL,
PRIMARY KEY (`per_id`)
) ENGINE=InnoDB;

1. Lets start with the MySQL Connection, I named this file dbcommon.php. Besure to change the username, password and database to your own.

mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("databasename") or die(mysql_error());

2. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-18 alignnone" title="percentss" src="http://www.blueicestudios.com/wp-content/uploads/2009/06/percentss.gif" alt="percentss" width="263" height="152" /></p>
<div style="font-size:12px; color:#333333;">Source Files: <a href="http://www.blueicestudios.com/percent/percent.zip">DOWNLOAD</a></div>
<div style="font-size:12px; color:#333333;">View working examples here: <a href="http://www.blueicestudios.com/percent/" target="_blank">DEMO</a></div>
<p>MySQL Table, used for example.</p>
<pre class="brush:sql">
CREATE TABLE IF NOT EXISTS `percent` (
`per_id` int(11) NOT NULL auto_increment,
`per_num` varchar(255) NOT NULL,
PRIMARY KEY (`per_id`)
) ENGINE=InnoDB;
</pre>
<p>1. Lets start with the MySQL Connection, I named this file <strong>dbcommon.php</strong>. Besure to change the username, password and database to your own.</p>
<pre class="brush:php">
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("databasename") or die(mysql_error());
</pre>
<p>2. <strong>function.php</strong> will contains the script for the query and bar. I setup the 4 function examples as in the demo.</p>
<pre class="brush:php">
function percent_full(){

  $result = mysql_query("SELECT * FROM percent")
  or die(mysql_error());

	 while($full = mysql_fetch_array( $result )) {
		echo '
<div id="bar_wrap_full">
<div style="height:'.(100-$full['per_num']).'px;"></div>
<div class="top"></div>
<div id="bar" class="center" style="height:'.($full['per_num']).'px;"></div>
<div class="bottom"></div>
<div class="num">'.($full['per_num']).'%</div>
<div style="text-align:center;">id:'.($full['per_id']).'</div>
</div>

		';
	 } 

}

function percent_button(){

  $result = mysql_query("SELECT * FROM percent")
  or die(mysql_error());

	 while($button = mysql_fetch_array( $result )) {
		echo '
<div id="bar_wrap_button">
<div style="height:'.(100-$button['per_num']).'px;"></div>
<div class="top"></div>
<div id="bar" class="center"></div>
<div class="bottom"></div>
</div>

		';
	 }

}

function percent_donation_full(){

  $result = mysql_query("SELECT * FROM percent WHERE per_id=18")
  or die(mysql_error());

	 while($donation_full = mysql_fetch_array( $result )) {
		echo '
<div id="bar_wrap_donation_full">
<div style="height:'.(100-$donation_full['per_num']).'px;"></div>
<div class="top">
<div class="num"> $'.($donation_full['per_num']).'</div>
</div>
<div id="bar" class="center" style="height:'.($donation_full['per_num']).'px;"></div>
<div class="bottom"></div>
</div>

		';
	 } 

}

function percent_donation_button(){

  $result = mysql_query("SELECT * FROM percent WHERE per_id=18")
  or die(mysql_error());

	 while($donation_button = mysql_fetch_array( $result )) {
		echo '
<div id="bar_wrap_donation_button">
<div style="height:'.(100-$donation_button['per_num']).'px;"></div>
<div class="top">
<div class="num"> $'.($donation_button['per_num']).'</div>
</div>
<div id="bar" class="center"></div>
<div class="bottom"></div>
</div>

		';
	 } 

}
</pre>
<p>3. <strong>style.css</strong> page will control the way the bars are shown.</p>
<pre class="brush:css">
@charset "utf-8";
#no-margin {
margin:0px;
}
/* Begin Percentage Bar Full */
#bar_wrap_full {
width:24px;
height:106px;
background:url(img/measure.gif) no-repeat right;
font-size:9px;
font:Arial, Helvetica, sans-serif;
color:#999;
float:left;
margin-right:20px;
}

#bar_wrap_full div.top {
width:20px;
height:3px;
background:url(img/bar_top.gif) no-repeat;
}

#bar_wrap_full div.center {
width:20px;
background:url(img/bar_cent.gif) repeat-y;
}

#bar_wrap_full div.bottom {
width:20px;
height:3px;
background:url(img/bar_bot.gif) no-repeat;
}

#bar_wrap_full div.num {
text-align:center;
}

#bar_wrap_full div.overlay {
background:url(img/lines.png) no-repeat;
width:24px;
height:106px;
}
/* End Percentage Bar Full */

/* Begin Percentage Bar Button */
#bar_wrap_button {
width:24px;
height:106px;
background: url(img/measure_buttons.gif) no-repeat right;
font-size:9px;
font:Arial, Helvetica, sans-serif;
color:#999;
float:left;
margin-right:20px;
}

#bar_wrap_button div.top {
width:20px;
height:3px;
background:url(img/bar_top.gif) no-repeat;
}

#bar_wrap_button div.center {
width:20px;
background:url(img/bar_cent.gif) repeat-y;
}

#bar_wrap_button div.bottom {
width:20px;
height:3px;
background:url(img/bar_bot.gif) no-repeat;
}

#bar_wrap_button div.num {
text-align:center;
}

#bar_wrap_button div.overlay {
background: url(img/stripes.png) bottom;
width:24px;
height:auto;
}

/* End Percentage Bar Button */

/* Begin Percentage Bar Full */
#bar_wrap_donation_full {
width:24px;
height:106px;
background:url(img/measure.gif) no-repeat right;
font-size:9px;
font:Arial, Helvetica, sans-serif;
color:#999;
float:left;
margin-right:20px;
}

#bar_wrap_donation_full div.top {
width:50px;
height:3px;
background:url(img/bar_top.gif) no-repeat left;
}

#bar_wrap_donation_full div.center {
width:20px;
background:url(img/bar_cent.gif) repeat-y;
}

#bar_wrap_donation_full div.bottom {
width:20px;
height:3px;
background:url(img/bar_bot.gif) no-repeat;
}

#bar_wrap_donation_full div.num {
text-align:center;
margin-left:20px;
line-height:0;
}

#bar_wrap_donation_full div.overlay {
background:url(img/lines.png) no-repeat;
width:24px;
height:106px;
}
/* End Percentage Bar Full */

/* Begin Percentage Bar button */
#bar_wrap_donation_button {
width:24px;
height:106px;
background:url(img/measure_buttons.gif) no-repeat right;
font-size:9px;
font:Arial, Helvetica, sans-serif;
color:#999;
float:left;
margin-right:20px;
}

#bar_wrap_donation_button div.top {
width:50px;
height:3px;
background:url(img/bar_top.gif) no-repeat left;
}

#bar_wrap_donation_button div.center {
width:20px;
background:url(img/bar_cent.gif) repeat-y;
}

#bar_wrap_donation_button div.bottom {
width:20px;
height:3px;
background:url(img/bar_bot.gif) no-repeat;
}

#bar_wrap_donation_button div.num {
text-align:center;
margin-left:20px;
line-height:0;
}

#bar_wrap_donation_button div.overlay {
background:url(img/lines.png) no-repeat;
width:24px;
height:106px;
}
/* End Percentage Bar Full */
</pre>
<p>4. <strong>index.php</strong><br />
Lets add the database connection and functions.</p>
<pre class="brush:php">
include('dbcommon.php');
include('function.php');
</pre>
<p>in the body we will call the functions.</p>
<pre class="brush:php">
percent_full();

percent_button();

percent_donation_full();

percent_donation_button();
</pre>
<hr />
<div style="font-size:12px; color:#333333;">Download, contains images, css, php: <a href="http://www.blueicestudios.com/percent/percent.zip">percentage_bar.zip</a></div>
<div style="font-size:12px; color:#333333;">View a working examples here: <a href="http://www.blueicestudios.com/percent/" target="_blank">demo</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.blueicestudios.com/php-percentage-bar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
