Home Backend Development PHP Tutorial How to calculate the percentage of progress bar displayed at the end of voting

How to calculate the percentage of progress bar displayed at the end of voting

Mar 24, 2017 pm 02:49 PM
vote percentage

A voting result I wrote myself shows that the progress bar with the most votes is set to 100%.

public class voteresult : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlTableCell td_vote;
protected System.Web.UI.HtmlControls.HtmlTable tab_result;
private void Page_Load(object sender, System.EventArgs e)// 在此处放置用户代码以初始化页面
{
tab_result=new HtmlTable();
string voteid=Request.Params["voteid"];
string optionid=Request.Params["optionid"];
CommonFunction.SQLConnection scon=new SQLConnection();
System.Data.DataTable dt;
System.Web.UI.HtmlControls.HtmlTableCell tc;
System.Web.UI.HtmlControls.HtmlTableRow tr;
string sql="";
sql="update voteinfo set optioncount=optioncount+1 where voteid="+voteid+" and optionid="+optionid;
scon.OperationRecord(sql);
sql="select optionstr,optioncount from voteinfo where voteid="+voteid;dt=scon.Query(sql);
int i=0;
int length=0;
while(i<dt.Rows.Count)
{
if(length<(int)dt.Rows[i].ItemArray[1])
length=(int)dt.Rows[i].ItemArray[1];
i++;
}
i=0;
td_vote.InnerHtml="<table border=\"1\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">";
while(i<dt.Rows.Count)
{
td_vote.InnerHtml+="<tr>";
td_vote.InnerHtml+="<td>";
td_vote.InnerHtml+=(string)dt.Rows[i].ItemArray[0];
td_vote.InnerHtml+="</td><td width=\"200\">";
//tc=new HtmlTableCell();
//tr=new HtmlTableRow();
//tc.InnerText=
//tr.Cells.Add(tc);
//tc=new HtmlTableCell();
td_vote.InnerHtml+="<img src=\"images/long.gif\" width=\""+(((int)dt.Rows[i].ItemArray[1]*100/length)*2)+"\" height=\"9\">";
//tc.InnerHtml=
//tr.Cells.Add(tc);
td_vote.InnerHtml+="</td><td>";
td_vote.InnerHtml+=((int)dt.Rows[i].ItemArray[1]).ToString();;
//tc=new HtmlTableCell();
//tc.InnerText=
td_vote.InnerHtml+="</td></tr>";
i++;
}
td_vote.InnerHtml+="</table>";
}
Copy after login

Related articles:

How to ensure that the sum of each part is 1 when calculating percentages in PHP

php sector ratio percentage display program Code

PHP execution progress percentage code

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
How to initiate WeChat voting How to initiate WeChat voting Feb 23, 2024 pm 12:20 PM

How to initiate WeChat voting? You can initiate voting function in WeChat, but most users don’t know how to initiate voting function in WeChat. Next is the graphic tutorial on how to initiate WeChat voting brought by the editor. Interested users please hurry up Come and take a look! WeChat usage tutorial How to initiate WeChat voting 1. First open the WeChat APP, click on the search box at the top of the main page to enter [Voting] and click [Group Voting] as shown below; 2. Then enter the group voting applet page and click [+ Voting] service button; 3. Finally, edit the content on the create group voting page to initiate voting.

How to convert fraction to percentage in Python? How to convert fraction to percentage in Python? Aug 25, 2023 pm 01:25 PM

Fractions and percentages are two basic mathematical concepts used in various fields such as finance, data analysis, and statistics. Converting a fraction to a percentage is a simple but necessary operation that allows us to represent fractional values ​​in a more understandable way. Python, one of the most popular programming languages, offers several methods for converting fractions to percentages, and understanding these methods is crucial for anyone working with data in Python. This article takes an in-depth look at converting fractions to percentages in Python. We'll explore different ways to do this and provide examples to help you understand each method. Whether you are a beginner or an experienced Python programmer, this article gives you the key to doing this in Python

Python program to get percentage of word frequency Python program to get percentage of word frequency Sep 08, 2023 pm 06:29 PM

In this article, we will learn how to get word frequency as a percentage in Python. Suppose we have obtained a list of string inputs. Now, we will find the percentage of each word in the given list of input strings. The formula (OccurrenceofXword/Totalwords)*100 uses the sum(), Counter(), join() and split() functions. Use the join(), split() and count() functions. Use the countOf() function of the operator module. Method 1: Use sum(), Counter(), join() and split() functions join() is Py

How to vote on Weibo Night_How to vote on Weibo Night How to vote on Weibo Night_How to vote on Weibo Night Mar 29, 2024 pm 06:12 PM

1. Open the latest version of Weibo on your mobile phone and enter it. 2. Enter Weibo Night and find the official Weibo account to enter. 3. After entering, the pinned Weibo will open, and there will be "Departure to Weibo Night". We can click on the blue word. 4. Enter the main interface, scroll down to see your favorite celebrity, and click the voting button. 5. His profile will then be displayed. Click the voting button below or click all to vote for him. 6. After voting, the interface will prompt us with the number of votes we cast. If we insist on voting every day, we will get more votes in the future.

World of Warcraft: Multiple media voting results, player return rate is amazing, even if the point card increase is 10 times, you still want to play World of Warcraft: Multiple media voting results, player return rate is amazing, even if the point card increase is 10 times, you still want to play Apr 15, 2024 pm 03:01 PM

After the official announcement of the national server, players' enthusiasm was very high. Many media also launched a vote on the willingness of players to return to the national server on public platforms. Let's take a look at the data of each vote. The first poll was "Which Blizzard game is your favorite" initiated by Sina Technology. I thought that World of Warcraft had the largest number of players, but it turned out that Hearthstone was the real king. This once again proves the rumors after the closure of the national server - Hearthstone's revenue in the national server has always been ahead of World of Warcraft. It was not until the Classic server was launched that World of Warcraft caught up. The second poll was also initiated by Sina Technology "Will you still play Blizzard's national server when it returns?" As a result, only 40.6% of players chose to continue playing, 45.8% of players chose not to continue playing, and 13.6% of players chose Uncertain. want

A simple tutorial for voting in Tencent Conference A simple tutorial for voting in Tencent Conference Apr 02, 2024 pm 02:04 PM

1. Click [More] in the lower right corner of the meeting. 2. Select [Chat]. 3. Click the gear settings icon in the upper right corner. 4. Select [Only allow private chat hosts] in the dialog box. 5. Return to the chat interface, enter the voting option content, and choose to send it to all participants.

How to use Webman framework to implement online survey and voting functions? How to use Webman framework to implement online survey and voting functions? Jul 08, 2023 am 08:05 AM

How to use Webman framework to implement online survey and voting functions? Introduction: With the rapid development of the Internet, more and more people have begun to actively participate in various surveys and voting activities. In order to facilitate users to participate in and manage these activities, we need an easy-to-use and powerful online survey and voting system. This article will introduce how to use the Webman framework to achieve this function. 1. Introduction to the Webman framework Webman is a lightweight Web framework developed based on the Python language. It provides a simple and easy-to-use

Developing a web voting application using JavaScript Developing a web voting application using JavaScript Aug 10, 2023 am 09:33 AM

Using JavaScript to develop web voting applications With the development of the Internet, online voting has become a common way to collect user opinions and feedback. In order to facilitate users to participate in voting activities, it is very necessary to develop a simple web voting application. This article will introduce how to use JavaScript to develop a web voting application, and attach corresponding code examples. Preparation work First, we need to add a voting area and some option buttons to the web page, where users can choose their favorite options.

See all articles