[PHP] [WITH SOURCE] Simple Progress Bar

Results 1 to 5 of 5
  1. #1
    Web Developer Markshall is offline
    MemberRank
    Oct 2009 Join Date
    EnglandLocation
    628Posts

    [PHP] [WITH SOURCE] Simple Progress Bar

    This is just a simple progress bar script I made with in 30 minutes in PHP.

    It gets the value of the percentage from the URL via $_GET and if it is empty, not numeric or it is more than 100, it will set its default value to 100.
    The script also writes the value of percentage slap-bang in the centre of the image.

    I will post the script below, but you will need to manually save the images yourself, alternatively, you can download the full package by clicking here.

    progressbar.php
    PHP Code:
    <?php
    //fix headers
    ob_start();

    //create the image
    $progress imagecreate20828 );

    //start the image
    $start imagecreatefrompng"start.png" );
    imagecopy$progress$start0000imagesx$start ), imagesy$start ) );

    //get value of percentage
    $percent strip_tags$_GET['p'] );
    if( ( empty( 
    $percent ) ) || ( $percent 100 ) || ( !is_numeric$percent ) ) ) $percent "100";

    //put the middle image in
    $middle imagecreatefrompng"middle.png" );
    for( 
    $i 6$i <= ( $percent ); $i++ )
    {
        
    imagecopy$progress$middle$i000imagesx$middle ), imagesy$middle ) );
    }

    //put the percentage value in text
    $black imagecolorallocate$progress00);
    imagestring$progress4, ( $i ) - 76$percent "%"$black );

    //end the image
    $end imagecreatefrompng"end.png" );
    imagecopy$progress$end$i000imagesx$end ), imagesy$end ) );

    //output the image
    header"Content-Type: image/PNG" );
    imagepng$progress );
    imagedestroy$progress );

    ob_flush();
    ?>
    Save these images in the same directory as progessbar.php

    start.png
    http://www.mark-eriksson.com/projects/ProgressBar/start.png

    middle.png
    http://www.mark-eriksson.com/projects/ProgressBar/middle.png

    end.png
    http://www.mark-eriksson.com/projects/ProgressBar/end.png

    I hope you enjoy this, if you use this please leave credits ;)

    If you want to see a live demo to this, click here

    The Password to the .RAR file is (as always)
    Code:
    m0nstadot
    Thanks,
    - m0nsta.


  2. #2
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [PHP] [WITH SOURCE] Simple Progress Bar

    this is cool n all but with the lower number percent it doesnt show the way you want. it would be better if you had a fixed bg with the red as the slider to show percentage of completion.

  3. #3
    Account Upgraded | Title Enabled! Putako is offline
    MemberRank
    Mar 2011 Join Date
    CanadaLocation
    542Posts

    Re: [PHP] [WITH SOURCE] Simple Progress Bar

    Why don't you have a background and then print the amount on there instead of a size? Or have it so it has like say my number was 45 it would be 45% lighter then dark and have the percentage?

  4. #4
    Infraction Baɴɴed holthelper is offline
    MemberRank
    Apr 2008 Join Date
    1,765Posts

    Re: [PHP] [WITH SOURCE] Simple Progress Bar

    Quote Originally Posted by Putako View Post
    Why don't you have a background and then print the amount on there instead of a size? Or have it so it has like say my number was 45 it would be 45% lighter then dark and have the percentage?
    opacity = fail as a progress bar.

    for a progress bar you want to make it look and show like how you would want to look like.

  5. #5
    C# | C++ Emerica is offline
    MemberRank
    Oct 2010 Join Date
    GermanyLocation
    437Posts

    Re: [PHP] [WITH SOURCE] Simple Progress Bar

    wow, I was searching this PHP Script. Thanks !



Advertisement