Grab complex data from mysql and show them using php

Yassine

I have been working on my PHP script for a while now but I am currently stuck in complex data grab and show as a table.

I have a MySQL table structured like this:

ID (AI) / UID / DYNA / CNT / QID
1       / 8   / car / 0    / 9
2       / 2   / bal / 1    / 9
3       / 0   / car / 0    / 8 
4       / 3   / lov / 1    / 2
5       / 6   / bal / 1    / 9 
6       / 9   / cal / 0    / 9
7       / 11  / los / 1    / 9

And I want to grab this data and structure it like this (The data is selected by qid):

DYNA / CAR / BAL / LOS
CNT /   0  / 2   / 1

The CNT table is the total of CNT in the database for example "car" in the database have two records their cnt is 0 and 0 so 0 + 0 = 0 So I think the query might be:

Select * from TABLE where qid = 9 ....
Kamrul Khan

Try this query:

select DYNA, sum(CNT) as CNT from table where QID = 9 group by DYNA;

It should give you an output like

DYNA | CNT
----------
CAR  | 0
BAL  | 2
LOS  | 1

UPDATE

If you also want to know the number of records in each group add a count in your query which is:

select DYNA, count(*) as num, sum(CNT) as CNT from table where QID = 9 group by DYNA;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Clickable data displayed from mysql using PHP

From Dev

insert data from JSON into mysql using php

From Dev

JSON wont show mysql data correctly :using php

From Dev

Using Tweepy to grab grab coordinates and plot them

From Dev

MySQL - Get column names from table and display them (using PHP)

From Dev

STRTOTIME take date and data from mysql and concatenate them on php

From Dev

Filter data from MySQL using WHERE or PHP?

From Dev

retrieve data from database and show them in bar chart using MPAndroidChart in android

From Dev

Extraction data from MySQL table using PHP

From Dev

Getting data from complex nested JSON object (using PHP)

From Dev

Show Markers on google map by using data from mysql in php

From Dev

Using Tweepy to grab grab coordinates and plot them

From Dev

Using jQuery to grab data from JSON

From Dev

Show all data from Mysql Database by category wise using php

From Dev

MySQL - Get column names from table and display them (using PHP)

From Dev

Grab variable data from .js an post to a php

From Dev

How to show this structured info from database using mySQL/PHP?

From Dev

Editing data from mysql table using php

From Dev

Using PHP, get data from MySQL and display it

From Dev

PHP: Show data from mysql database in table

From Dev

Sending data from Mysql with Json using PHP

From Dev

PHP AJAX: retrieve data from mysql and show them in form

From Dev

Extraction data from MySQL table using PHP

From Dev

Show Markers on google map by using data from mysql in php

From Dev

How to show table from MySQL database using php and html

From Dev

Insert data from Javascript to MySQL using PHP

From Dev

show the data from complex json data in php

From Dev

How to filter data from mysql and show it in jtable using java

From Dev

Show data from database to Array Multidimensi using php and mysql

Related Related

  1. 1

    Clickable data displayed from mysql using PHP

  2. 2

    insert data from JSON into mysql using php

  3. 3

    JSON wont show mysql data correctly :using php

  4. 4

    Using Tweepy to grab grab coordinates and plot them

  5. 5

    MySQL - Get column names from table and display them (using PHP)

  6. 6

    STRTOTIME take date and data from mysql and concatenate them on php

  7. 7

    Filter data from MySQL using WHERE or PHP?

  8. 8

    retrieve data from database and show them in bar chart using MPAndroidChart in android

  9. 9

    Extraction data from MySQL table using PHP

  10. 10

    Getting data from complex nested JSON object (using PHP)

  11. 11

    Show Markers on google map by using data from mysql in php

  12. 12

    Using Tweepy to grab grab coordinates and plot them

  13. 13

    Using jQuery to grab data from JSON

  14. 14

    Show all data from Mysql Database by category wise using php

  15. 15

    MySQL - Get column names from table and display them (using PHP)

  16. 16

    Grab variable data from .js an post to a php

  17. 17

    How to show this structured info from database using mySQL/PHP?

  18. 18

    Editing data from mysql table using php

  19. 19

    Using PHP, get data from MySQL and display it

  20. 20

    PHP: Show data from mysql database in table

  21. 21

    Sending data from Mysql with Json using PHP

  22. 22

    PHP AJAX: retrieve data from mysql and show them in form

  23. 23

    Extraction data from MySQL table using PHP

  24. 24

    Show Markers on google map by using data from mysql in php

  25. 25

    How to show table from MySQL database using php and html

  26. 26

    Insert data from Javascript to MySQL using PHP

  27. 27

    show the data from complex json data in php

  28. 28

    How to filter data from mysql and show it in jtable using java

  29. 29

    Show data from database to Array Multidimensi using php and mysql

HotTag

Archive