简体   繁体   中英

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. 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.

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,

You can use where clause to get the count of open and pending status values. 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());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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