如何在mysql,php中找到许多列的模式 [英] How to find the mode for many columns in mysql,php

查看:51
本文介绍了如何在mysql,php中找到许多列的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...我是php的新手,我在这里有几个问题...



1.我正试图找到模式值mysql中的以下查询。查询即Kra,Year,Max(Rating1),Max(Rating2),Max(Rating3)...任务是显示模式,即Total_Rating。有2种类型的评级,即Good或Problematic..如果Max(Rating1)=Good,Max(Rating2)=Good,Max(Rating3)=有问题,模式或Total_Rating =Good.Below是编码,但它没有显示为假设to ...请告知...

Hi everyone...am new in php and i have a few questions here...

1.I'm trying to find the mode value for the following query in mysql. The query ie Kra,Year,Max(Rating1),Max(Rating2),Max(Rating3)...the task is to display the mode ie Total_Rating.There are 2 types of rating ie "Good" or "Problematic"..if Max(Rating1)="Good", Max(Rating2)="Good",Max(Rating3)="Problematic", the mode or Total_Rating="Good".Below is the coding but it didn't display as what suppose to...please advise...

SELECT Max(Max(Rating1),Max(Rating2),Max(Rating3)) as mode FROM progress GROUP BY (Max(Rating1),Max(Rating2),Max(Rating3)) ORDER BY mode DESC LIMIT 1;





2.获得Total_Rating后,我想将Total_Rating显示为颜色......编码如下......



2.After getting the Total_Rating, i want to display the Total_Rating as color...The coding as follows...

<?php
$con=mysqli_connect("localhost","pqa","","pq");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM total_rating");
echo "<table border="1">
<tr>
<th>KRA(Key Result Areas)</th>
<th>Total Rating</th>
<th>Status</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['Kra'] . "</td>";
$class = ($row['mode'] == 'good') ? 'green' : 'red';
echo "<td class="$class">" . $row['Total_Rating'] . "</td>";
echo "</tr>";
}
echo "</table>";

switch ($row['Total_Rating']) { 
case "good"; 
    echo "#008000"; 
    break; 
default;     
    echo "#FF0000"; 
    break;     
} 
mysqli_close($con);
?>



非常感谢您的帮助...


Thanks a lot for your help...

推荐答案

con = mysqli_connect( localhost pqa pq);
// 检查连接
if (mysqli_connect_errno()){
echo 无法连接到MySQL:。 mysqli_connect_error();
}
con=mysqli_connect("localhost","pqa","","pq"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }


result = mysqli_query(
result = mysqli_query(


con , SELECT * FROM total_rating);
echo < table border = 1 >
< tr>
< th> KRA(关键结果区域)< / th>
< th>总评分< / th>
< th>状态< / th>
< / tr>
;
while(
con,"SELECT * FROM total_rating"); echo "<table border="1"> <tr> <th>KRA(Key Result Areas)</th> <th>Total Rating</th> <th>Status</th> </tr>"; while(


这篇关于如何在mysql,php中找到许多列的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆