|
|
|
ต้องการแสดงสถิติการซ่อมบำรุง php mysql นับจำนวนจาก database ทำอย่างไร |
|
|
|
|
|
|
|
ค้นหาในบทความครับ COUNT GROUP BY
|
|
|
|
|
Date :
2013-08-05 19:25:09 |
By :
{Cyberman} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
COUNT / GROUP BY
|
|
|
|
|
Date :
2013-08-06 05:39:27 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (SQL)
SELECT DISTINCT
job_status,
COUNT(job_status) AS Total
FROM
TableJobs
GROUP BY
job_status
|
|
|
|
|
Date :
2013-08-06 07:03:05 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณ คุณ Krungsri มากครับ และต้องการให้ออกรายงานแบบ html ทำอย่างไรครับ ขอโค้ด php ด้วยครับ
|
|
|
|
|
Date :
2013-08-06 11:43:13 |
By :
tim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ แต่อยากให้เรียงจากมากไปหาน้อย ของยอดจำนวน จะทำอย่างไร
Code (PHP)
<?php require_once('../Connections/myconnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_myconnect, $myconnect);
$query_Recordset1 = "SELECT DISTINCT job_status, COUNT( job_status ) AS Total FROM job GROUP BY job_status";
$Recordset1 = mysql_query($query_Recordset1, $myconnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Show Status</title>
</head>
<body>
<table border="1">
<tr>
<td><div align="center">รายการ</div></td>
<td><div align="center">จำนวน</div></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['job_status']; ?></td>
<td><div align="center"><?php echo $row_Recordset1['Total']; ?></div></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
|
|
|
|
|
Date :
2013-08-06 13:35:03 |
By :
tim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|