NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Create a table/css/div bar dynamically with php

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
6 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 06-29-2005, 12:22 PM THREAD STARTER               #1 (permalink)
Account Suspended
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
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:
<?
????: NamePros.com http://www.namepros.com/code/102832-create-table-css-div-bar-dynamically.html
    
function create_bar($width$show_text '')
    {
        
$bar '';    
        if ( 
strstr($width'%') )
        {
            
$width intval(str_replace('%'''$width));
            if(
$width 0)
            {
                
$width = ( intval($width) <= 100 ) ? $width '%' '100%';
            }
        }
    
????: NamePros.com http://www.namepros.com/showthread.php?t=102832
        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...
axilant is offline  
Old 06-29-2005, 12:53 PM   #2 (permalink)
NamePros Member
Join Date: Oct 2003
Posts: 126
i386 is an unknown quantity at this point
 



Cool, thanks for sharing!
i386 is offline  
Old 06-29-2005, 11:56 PM   #3 (permalink)
Account Suspended
Join Date: May 2005
Location: NY, USA
Posts: 283
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  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


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

 
All times are GMT -7. The time now is 02:04 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger