473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Count numbers group wise according to identical time in PHP and MYSQL

19
Dear Xperts,

In my database table some fault code type records are inserted and the values are like bellows:

Error:2/FC:10; 00:15:13 16/03/2009;
Error:2/FC:20; 00:15:15 16/03/2009;
Error:2/FC:30; 00:15:16 16/03/2009;
Error:2/FC:40; 00:15:20 16/03/2009;

Error:3/FC:3; 00:20:13 16/03/2009;
Error:3/FC:6; 00:20:15 16/03/2009;
Error:3/FC:9; 00:20:16 16/03/2009;
Error:3/FC:12; 00:20:25 16/03/2009;
Error:3/FC:15; 00:20:23 16/03/2009;
Error:3/FC:18; 00:20:26 16/03/2009;


The database values contains in the following variables:

$error_name[]= row[‘$db_error_name’]; // contains all the values of 1st column
$error_time[]= row[‘$db_error_time’]; // contains all the values of 2nd column


I need an SQL query/PHP statement order by same Error code(Error:2/ Error:3 )so that I can print the following output in page when it occurs at the same time (time format: hh:mm only; ex: 00:15/00:20).

Note: Same Error code(Error:2/Error:3) types FC numbers have to count when it occurs at the same time (hh:mm dd/mm/yy).

Output:

4 Fault(10,20,30,40)found // under Error:2 & time 00:15 16/03/2009;

6 Fault(3,6,9,12,15,18)found //under Error:3 & time 00:15 16/03/2009;


I am waiting for your kind valued reply.

Regards
AHMURAD
Mar 20 '09 #1
4 2925
ahmurad
19
Dear Xperts,

In my database table some fault code type records are inserted and the values are like bellows:

Error:2/FC:10; 00:15:13 16/03/2009;
Error:2/FC:20; 00:15:15 16/03/2009;
Error:2/FC:30; 00:15:16 16/03/2009;
Error:2/FC:40; 00:15:20 16/03/2009;

Error:3/FC:3; 00:20:13 16/03/2009;
Error:3/FC:6; 00:20:15 16/03/2009;
Error:3/FC:9; 00:20:16 16/03/2009;
Error:3/FC:12; 00:20:25 16/03/2009;
Error:3/FC:15; 00:20:23 16/03/2009;
Error:3/FC:18; 00:20:26 16/03/2009;

The database values contains in the following variables:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $error_name[]= row[‘$db_error_name’]; // contains all the values of 1st column
  3. $error_time[]= row[‘$db_error_time’]; // contains all the values of  2nd column
  4.  
  5.  
I need an SQL query/PHP statement order by same Error code(Error:2/ Error:3 )so that I can print the following output in page when it occurs at the same time (time format: hh:mm only; ex: 00:15/00:20).

Note: Same Error code(Error:2/Error:3) types FC numbers have to count when it occurs at the same time (hh:mm dd/mm/yy).

Output:

4 Fault(10,20,30,40)found // under Error:2 & time 00:15 16/03/2009;
6 Fault(3,6,9,12,15,18)found //under Error:3 & time 00:15 16/03/2009;


I am waiting for your kind valued reply.

Regards
AHMURAD
Mar 20 '09 #2
ahmurad
19
Dear Xperts,

In my MYSQL database table some fault code type records are inserted and the values are like bellows:

Error:2/FC:10; 00:15:13 16/03/2009;
Error:2/FC:20; 00:15:15 16/03/2009;
Error:2/FC:30; 00:15:16 16/03/2009;
Error:2/FC:40; 00:15:20 16/03/2009;

Error:3/FC:3; 00:20:13 16/03/2009;
Error:3/FC:6; 00:20:15 16/03/2009;
Error:3/FC:9; 00:20:16 16/03/2009;
Error:3/FC:12; 00:20:25 16/03/2009;
Error:3/FC:15; 00:20:23 16/03/2009;
Error:3/FC:18; 00:20:26 16/03/2009;


The database values contains in the following variables:

Expand|Select|Wrap|Line Numbers
  1. $error_name[]= row[‘$db_error_name’]; // contains all the values of 1st column
  2. $error_time[]= row[‘$db_error_time’]; // contains all the values of  2nd column
  3.  
I need an SQL query order by same Error code(Error:2/ Error:3 )so that I can print the following output in page when it occurs at the same time (time format: hh:mm only; ex: 00:15/00:20).

Note: Same Error code(Error:2/Error:3) types FC numbers have to count when it occurs at the same time (hh:mm dd/mm/yy).

Output:

4 Fault(10,20,30,40)found // under Error:2 & time 00:15 16/03/2009;

6 Fault(3,6,9,12,15,18)found //under Error:3 & time 00:15 16/03/2009;

I am waiting for your kind valued reply.

Regards
AHMURAD
Mar 20 '09 #3
RedSon
5,000 Expert 4TB
I have moved your posts from the jobs forum where they were automatically moderated. Please do not post there again. You posted three times because I suspect you were not able to see your other posts. You do not need to double or triple posts, if the server tells you that your post was successful then there is likely another reason that it is not visible. You are encouraged to read the FAQ under the help link at the top of the page.
Mar 20 '09 #4
ahmurad
19
Dear Brothers,

I have simplified the problem. Please see the Present and Expected Output Status. Please give me a solution modifying the PHP/MYSQL code. I am not so familiar with group by, order by, having clauses.

DB Table:

Error_Code FC_No FC_Time

Error:2 FC:10 00:15:13
Error:2 FC:20 00:15:15
Error:2 FC:30 00:15:16
Error:2 FC:40 00:15:20
Error:3 FC:3 00:20:13
Error:3 FC:6 00:20:15
Error:3 FC:9 00:20:16
Error:3 FC:12 00:20:20
Error:3 FC:15 00:20:16
Error:3 FC:18 00:20:20

[code=PHP]

$view= mysql_query("SELECT * FROM db_table WHERE Occurrence_Date = '".$fdate."' ");

while( $searchresult = mysql_fetch_array($view) )
{
$error_code = $searchresult[‘db_error_code’]; //contains all the values of Error_Code
$error_no = $searchresult[‘db_error_no’]; //contains all the values of FC_No
$error_time = $searchresult[‘db_error_time’]; //contains all the values of FC_Time
Print “1 Fault($error_no)found”;
}

[/CODE=PHP]

Hints: Same Error_Code(Error:2/Error:3) types FC_No have to count when it occurs at the same time (hh:mm).

Present Output :

//Under Error:2
1 Fault(10)found
1 Fault(20)found
1 Fault(30)found
1 Fault(40)found

//Under Error:3
1 Fault(3)found
1 Fault(6)found
1 Fault(9)found
1 Fault(12)found
1 Fault(15)found
1 Fault(18)found

Expected output:

4 Fault(10,20,30,40)found // under Error:2 & time 00:15
6 Fault(3,6,9,12,15,18)found //under Error:3 & time 00:20
Mar 21 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: konsu | last post by:
hello, suppose a hypothetical table called 'table' with one field called 'field' of an arbitrary type. the query select count(*) from table where field='value' group by field produces no...
6
by: Good Man | last post by:
Hi all Well, I didn't want to have to bring this question to someone else to answer, but I am truly flummoxed and could use some help. It all boils down to trying to find the number of jobs...
1
by: Puvendran | last post by:
Hi, Can someone please explain the following 1. Meaning of scan count as reported when "statistics io" is turned on prior to running a query. 2. In which situations could you have an...
8
by: Bri | last post by:
Greetings, After making various edits and deletes on aproximately 40,000 records in one table (on the Design Master) syncronization fails with Error 3052 - File Sharing Lock Count Exceeded....
10
by: Henk Ernst Blok | last post by:
Hi Posgres users/developers, Can anyone explain why PosgreSQL (version 7.4.5 on Linux) does a full table scan to compute a count(*) on a base table after a vacuum analyze has been done with no...
14
by: dottty | last post by:
Hi, i have a table that has the following fields: id, name, dept, pay 1, John, Sales, 4000 2, Peter, HR, 5000 etc. How do i count how many people there are in each dept with an sql query? ...
3
by: Auddog | last post by:
I have the following query that works in mysql: select id, order_no, price, count(item_no), sum(price) from production WHERE item_no = '27714' group by item_no; When I setup my query in php,...
16
by: Markus Dehmann | last post by:
According to several C++ tutorials, calling srand like this to initialize the random number generator seems to be standard: srand((unsigned)time(0)); But it leads to the same random number...
1
by: zafm86 | last post by:
Hi everyone! I'm sure my problem is pretty easy to solve but I've been working on it for a long and my my brain is not working correctly anymore. I'm working with an AS400 and I mhave to do an...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.