简体   繁体   English

根据唯一 ID 获取 php 中的计数

[英]Get count in php against unique ID

Need some help.需要一些帮助。 I have a DB with 4 fields and 1 column of Date of entry with time, as below and i want to get count of last entered values of status against Evaid if it's open or pending.我有一个包含 4 个字段和 1 列随时间输入的日期的数据库,如下所示,如果 Evaid 处于打开状态或未决状态,我想获取上次输入的状态值的计数。 I tried below code but it's getting last entered value from whole DB - but can't add a logic to get it against the Evaid.我尝试了下面的代码,但它从整个数据库中获取最后输入的值 - 但无法添加逻辑来获取它对抗 Evaid。

DisID   -  Evaid   -   Status
1       -  123     -    Open
2       -  123     -    In Process
3       -  123     -    Close
4       -  2222     -    Open
4       -  2222     -    Open
6       -  2222     -    Closed
7       -  456     -    Open
8       -  456     -    Open
9       -  456     -    Open
10      -  333     -    Open
11      -  333     -    Open

include 'ddmenu.php';
$result = mysql_query('SELECT * FROM disagreements ORDER BY srno DESC LIMIT 1' ) or die('Invalid query: ' . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo $row['evaid'];
echo $row['srno'];
}

mysql_free_result($result);

As what you are saying - i want to get count of last entered values of status against Evaid if it's open or pending,正如您所说的-如果 Evaid 处于打开状态或待处理状态,我想获取对 Evaid 的最后输入状态值的计数,

You can use where clause to get the count of open and pending status values.您可以使用 where 子句获取打开和挂起状态值的计数。 See below见下文

$result = mysql_query('SELECT count(*) as total FROM disagreements WHERE Status = 'open' OR Status = 'In Process' ORDER BY srno DESC LIMIT 1') or die('Invalid query: ' . mysql_error()); $result = mysql_query('SELECT count(*) as total FROM discrimess WHERE Status = 'open' OR Status = 'In Process' ORDER BY srno DESC LIMIT 1') or die('Invalid query: ' . mysql_error());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM