Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Gambar beberapa grafik dengan Flot, html, PHP, dan kueri MySql

Pertama-tama tampaknya agak aneh memiliki user_name2,time2,dll. untuk kueri kedua. Apakah itu benar-benar cara pengaturannya di DB Anda?

Bagaimanapun, inilah satu cara untuk menghasilkan plot dari dalam loop PHP Anda.

    echo('<div id="placeholder"></div>');
    echo('<script>');
    while($info = mysql_fetch_array( $data )) 
        { 
            $user = $info['user_name']; //It’s the name of user analyzed at the moment
            /*
            This query extract the first ten more recents values (order by time DESC)
            The data retrieved by the query are used to paint the 1° chart for emails sent by the user
            but I don't know how to do it recursively
            */
            $query = "SELECT user_name,mail_sent,mail_received,time FROM table1 WHERE user_name='$user' ORDER BY time DESC LIMIT 0,10";
            $result = mysql_query($query);
            $dataset1 = new Array();
            while($row = mysql_fetch_assoc($result))
                {
                    $row['time']=$row['time']*1000; //The time is in millisecond I need to multiply for 1000 in order to obtain the seconds
                     //the 'time'  row is the x-axis , the 'mail_send' row is the y-axsis
                    $dataset1[] = array($row['time'],$row['mail_sent']); //It contains the time value and the numbers of email sent from the user
                 }
            echo('$.plot( $(\'<div style="width:600px;height:300px;"></div>\').appendTo(\'#placeholder\'),'.json_encode($dataset1).',options);\n');
        }
    echo('</script>');



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bagaimana cara mengatur penyandian untuk kolom char tabel di Django?

  2. Fungsi Agregat MySQL tanpa klausa GROUP BY

  3. Utas Java dan MySQL

  4. Mengapa Saya Mendapatkan Kesalahan MySQL #1312 saat Menggunakan Prosedur Tersimpan Sederhana?

  5. Menanyakan jumlah item dari pohon