firefox53074 Posted July 19, 2016 Share Posted July 19, 2016 Need report in PHP to pull a total number of items that are sent to the queues in a particular day and for orders that are completed from the queues in a single day. There is a list of ten different queues that I'm needing to gather this data from and pull into a csv file. I'm needing to use an array with if-then statement or case statements. I'm not sure what other information I'm going to need or where to start at. example of the statementIN_Queue[ ]foreach ($in_queue as $item)case match 1112#test _cnt++;continue queue testselect distinct item_number from queue_test WHERE search_type = '1112';queue test 2 select distinct item_number from queue_test2 WHERE search_type = '1111';So for the two examples above I am just pulling the distinct item_number but I'm needing a total count of items that was submitted and completed for those queues on a single day. I have a list of ten queues that I need that information from. So I will need to pull the total count of submitted and have it output into a csv file into a column called test submitted and the completed go to test completed for day. Quote Link to comment https://forums.phpfreaks.com/topic/301511-gathering-data-for-a-daily-report/ Share on other sites More sharing options...
Barand Posted July 19, 2016 Share Posted July 19, 2016 First of all, whenever I see names like queue_test queue_test2 then alarm bells start ringing to alert of bad design. What is the current structure of those "queue_test" tables? Quote Link to comment https://forums.phpfreaks.com/topic/301511-gathering-data-for-a-daily-report/#findComment-1534653 Share on other sites More sharing options...
firefox53074 Posted July 19, 2016 Author Share Posted July 19, 2016 First of all, whenever I see names like queue_test queue_test2 then alarm bells start ringing to alert of bad design. What is the current structure of those "queue_test" tables? I'm not exactly sure what you mean by that? Those are just sample names that I chose for an example. Quote Link to comment https://forums.phpfreaks.com/topic/301511-gathering-data-for-a-daily-report/#findComment-1534659 Share on other sites More sharing options...
Barand Posted July 19, 2016 Share Posted July 19, 2016 It implies that each queue has a separate table. But as you don't care to share the table structure with us, that can only be an assumption. So I'll not waste any more time and wish you luck. Quote Link to comment https://forums.phpfreaks.com/topic/301511-gathering-data-for-a-daily-report/#findComment-1534660 Share on other sites More sharing options...
Psycho Posted July 19, 2016 Share Posted July 19, 2016 So for the two examples above I am just pulling the distinct item_number but I'm needing a total count of items that was submitted and completed for those queues on a single day. Then you don't need DISTINCT. Instead run the query for the records you want and 1) Use a GROUP BY on the item_number with a COUNT() clause in the select list. Something like this SELECT item_number, COUNT(item_number) as item_count FROM queue_test WHERE search_type = '1112' AND date_completed = CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/301511-gathering-data-for-a-daily-report/#findComment-1534661 Share on other sites More sharing options...
benanamen Posted July 19, 2016 Share Posted July 19, 2016 If you want a complete correct answer you will need to post your DB schema. Quote Link to comment https://forums.phpfreaks.com/topic/301511-gathering-data-for-a-daily-report/#findComment-1534662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.