Jump to content

Progress bar reading from SQL through php

Go to solution Solved by Guest,

Hi sorry i think i may be blind but i would like to delete this post as i have worked it out. 

Code: 

echo '<div class="inner" style="width:'.$row['Status'].'%;">';

Had to be changed to:
 

echo '<div class="inner" style="width:'.$row['PercentCompleted'].'%;">';

I am trying to create a progress bar that reads from a sql server. The field in the SQL server will be numbered from 25 - 100. The current code i have is as followed:

/*CSS Code */ .outer{    	height:18px;    	width:50px;    	border:solid 1px #000;    }    .inner{    	height:18px;    	width:<?php echo $percent ?>%;    	border-right:solid 1px #000;    	background: #f8ffe8; /* Old browsers */    	background: -moz-linear-gradient(top, #f8ffe8 0%, #e3f5ab 33%, #b7df2d 100%); /* FF3.6+ */    	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8ffe8), color-stop(33%,#e3f5ab), color-stop(100%,#b7df2d)); /* Chrome,Safari4+ */    	background: -webkit-linear-gradient(top, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* Chrome10+,Safari5.1+ */    	background: -o-linear-gradient(top, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* Opera 11.10+ */    	background: -ms-linear-gradient(top, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* IE10+ */    	background: linear-gradient(to bottom, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* W3C */    	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8ffe8', endColorstr='#b7df2d',GradientType=0 ); /* IE6-9 */    }
<html>/*php Code */<head><meta http-equiv="refresh" content="5"><link rel="stylesheet" type="text/css" href="./CSS/studentview.css"></head></body><?php//Create a connection to the serverINCLUDE ("connect.php");//Pull Data$sql = "SELECT FirstName, LastName, PercentCompleted FROM RepairTable ORDER BY PercentCompleted DESC";$stmt = sqlsrv_query( $conn, $sql );if( $stmt === false) {    die( print_r( sqlsrv_errors(), true) );}echo "<table class='table table-striped'>";echo "<thead>";echo "<tr><th>First Name</th><th>Last Name</th><th>Status</th></tr>";echo "</thead>";echo "<tbody>";while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {	echo "<tr><td>";	echo $row['FirstName'];	echo "</td><td>";	echo $row['LastName'];	echo '</td><td id="outer">';	echo '<div class="inner" style="width:'.$row['Status'].'%;">';	echo $row['PercentCompleted'];echo "%";	echo "</div>";	echo "</td></tr>";}echo "</tbody>";echo "</table>";//Free Up Resourcessqlsrv_free_stmt( $stmt);// Close the connection.sqlsrv_close( $conn );?><p style="font-size:12px;">Web Interface Created and Designed </br>by Andrew Bassett - 2015</p></body></html>
Link to comment
https://linustechtips.com/topic/380608-progress-bar-reading-from-sql-through-php/
Share on other sites

Link to post
Share on other sites

Hi sorry i think i may be blind but i would like to delete this post as i have worked it out. 

Code: 

echo '<div class="inner" style="width:'.$row['Status'].'%;">';

Had to be changed to:
 

echo '<div class="inner" style="width:'.$row['PercentCompleted'].'%;">';
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×