[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 06-29-2005, 12:22 PM   · #1
axilant
Account Closed
 
axilant's Avatar
 
Name: Cody Selzer
Location: /etc/passwd
Trader Rating: (40)
Join Date: May 2004
Posts: 2,194
NP$: 0.00 (Donate)
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
Member of the Month
July 2005
Create a table/css/div bar dynamically with php

Alright with my new project, i needed to use a bar to show a user how much space he/she is using... and i thought i would share this great function.
PHP Code:
<?
    
function create_bar($width, $show_text = '')
    {
        
$bar = '';    
        if (
strstr($width, '%') )
        {
            
$width = intval(str_replace('%', '', $width));
            if(
$width > 0)
            {
                
$width = ( intval($width) <= 100 ) ? $width . '%' : '100%';
            }
        }
    
        if(
$width > 0)
        {
            
$bar = "<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"10\">\n";
            
$bar .= "\t<tr>\n\t\t<td width=\"100%\" align=\"left\" style=\"border: 1px solid #AAAAAA; background-color: #CECECE;\" nowrap=\"nowrap\">";
            
$bar .= "\n\t\t\t<div style=\"background-color: #26E81C; margin: 2px; height: 10px; width: {$width}px;\">";
            if (
$show_text != "")
            {
                
$bar .= "\n\t\t\t\t<span style=\"font-size: 10px;\">$show_text</span>";
            }    
            
$bar .= "\n\t\t\t</div>\n\t\t</td>\n\t</tr>\n</table>";
        }    
           return
$bar;
    }
    print(
create_bar("10","10/100"));
?>

Create_bar(int percentage used..., string for text in the middle of the bar)

all comments/suggestions welcome...


Please register or log-in into NamePros to hide ads
axilant is offline   Reply With Quote
Old 06-29-2005, 12:53 PM   · #2
i386
NamePros Member
 
Trader Rating: (3)
Join Date: Oct 2003
Posts: 126
NP$: 182.00 (Donate)
i386 is an unknown quantity at this point
Cool, thanks for sharing!
i386 is offline   Reply With Quote
Old 06-29-2005, 11:56 PM   · #3
hasif
Account Closed
 
Name: Hasif Ahmed
Location: NY, USA
Trader Rating: (12)
Join Date: May 2005
Posts: 285
NP$: 45.00 (Donate)
hasif has a spectacular aura abouthasif has a spectacular aura about
before i use i wanna look at this in demo, is there anywhere you have installed this so that i can view.
hasif is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Getting started with PHP (The Basics) deadserious Webmaster Tutorials 60 11-17-2007 11:35 AM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 09:09 AM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 09:46 PM

Site Sponsors
http://www.mobisitetrader.com/ EscrowDNS Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 10:46 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0