473,657 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

19 New Member
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 2963
ahmurad
19 New Member
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 New Member
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 Recognized Expert Expert
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 New Member
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("SE LECT * FROM db_table WHERE Occurrence_Date = '".$fdate."' ");

while( $searchresult = mysql_fetch_arr ay($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(Erro r: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
1747
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 rows when run under the latest mysql. without "group by" it
6
1810
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 available in a particular state. I have two tables, one called STATES and one called WORK. Here are excerpts from both: STATES table: StateID | StateName | StateAbbr
1
3991
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 identical database running on two diferent servers , with identical database server configurations, running identical queries, with identical query plan,
8
2844
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. After reading the MS KB article 173006 (http://support.microsoft.com/default.aspx?scid=kb;en-us;173006) I increased the locks to 100,000 on the Replica PC and I still get the error. Since the defailt value is only 9500 I would have thought that...
10
4405
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 following updates that might have outdated any statistics. Strangly the explain command does give the correct number of tuples instantaniously from the catalog, as one would expect. Still the optimizer thinks it needs a full table scan to do count....
14
6592
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? I find this surprisingly difficult, given the fact that i can sum the total
3
3105
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, I use: $query2 = "SELECT id, order_no, price, count(item_no) as count from production where item_no = '27714";
16
8782
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 sequence on every program call if the program is called several times in a second! Isn't there a better method to seed the random numbers? Probably based on milliseconds instead of seconds? And integrating the process ID or current amount of free...
1
3612
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 "interface" in Access. It's like a little system to make a production plan. It must get information about part numbers, description, set where the part number belongs, quantity of part numbers that the set uses, stock number(this is a text value, it...
0
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8302
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8601
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.